help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org, "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
Subject: Re: Probabilistic crash on zsh 5.9 on x86_64
Date: Tue, 11 Apr 2023 17:29:20 +0100	[thread overview]
Message-ID: <5C4788C8-4E40-4565-AFE8-84D57949BC8C@ntlworld.com> (raw)
In-Reply-To: <48A7DCE2-AEC1-4777-949C-50917EDCECB1@kba.biglobe.ne.jp>

[-- Attachment #1: Type: text/plain, Size: 1657 bytes --]

(Please excuse illiterate response, I'm away but should be
back with a real computer in a day or so.)

This indicates something is wrong with the reference counting:
it shouldn't be possible for a shell code chunk to be visible
to the user without it being marked as having at least one reference.


On 11 April 2023 17:14:15 BST, "Jun. T" <takimoto-j@kba.biglobe.ne.jp> wrote:
>> 2023/04/09 6:36, Mikael Magnusson <mikachu@gmail.com> wrlte:
>> It seems to happen reliably for me every time, with these messages,
>> % MALLOC_CHECK_=3 zsh -fc 'TRAPEXIT() { ls }; TRAPEXIT'
>> 1: parse.c:2817: Heap EPROG has nref > 0
>> free(): invalid pointer
>> zsh: abort      MALLOC_CHECK_=3 zsh -fc 'TRAPEXIT() { ls }; TRAPEXIT'
>It seems memory pointed to by 'Eprog p' (in function freeeprog(),
>parse.c:2817) is already freed.
>If TRAPEXIT() is called directly, execshfunc(shf, ..) is called
>with shf pointing to the node "TRAPEXIT" in shfunctab.
>Then it calls
>doshfunc(shf, ..)
>  starttrapscope()			// exec.c:5821
>    unsettrap()				// signals.c:1079
>      shfunctab->freenode(shf)		// signals.c:982
>this means shf is freed by freeshfuncnode(shf). But doshfunc()
>continues to use shf (=shfunc in this function), and calls
>  runshfunc(prog=shf->funcdef, ..)	// exec.c:5963
>This leads to crash, of course.
>The simplest thing we can do would be just to prohibit
>users/scripts from calling TRAPEXIT() directly. I guess this
>can be done by, for example, rejecting (with error message)
>shf->node.nam=="TRAPEXIT" at the top of execshfunc(shf,..).
>But then users can't test TRAPEXIT manually.

[-- Attachment #2: Type: text/html, Size: 2233 bytes --]

  reply	other threads:[~2023-04-11 16:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-08 17:28 zsh bug report throwaway email thing
2023-04-08 21:36 ` Mikael Magnusson
2023-04-11 16:14   ` Jun. T
2023-04-11 16:29     ` Peter Stephenson [this message]
2023-04-13 10:47       ` Peter Stephenson
2023-04-13 11:12         ` Peter Stephenson
2023-04-13 13:02           ` Jun. T
2023-04-13 13:19             ` Peter Stephenson
2023-04-13 14:03               ` Peter Stephenson
2023-04-13 14:13                 ` Peter Stephenson
2023-04-13 16:40                 ` Jun. T
2023-04-13 16:55                   ` Peter Stephenson
2023-04-14  8:29                     ` Peter Stephenson
2023-04-14 12:21                       ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5C4788C8-4E40-4565-AFE8-84D57949BC8C@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).