From: "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Probabilistic crash on zsh 5.9 on x86_64
Date: Wed, 12 Apr 2023 01:14:15 +0900 [thread overview]
Message-ID: <48A7DCE2-AEC1-4777-949C-50917EDCECB1@kba.biglobe.ne.jp> (raw)
In-Reply-To: <CAHYJk3QaY_ejw2gCw5d1BzyvB4W3EyU7cb1TWtZpRhx=QSpw+w@mail.gmail.com>
> 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.
next prev parent reply other threads:[~2023-04-11 16:15 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 [this message]
2023-04-11 16:29 ` Peter Stephenson
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48A7DCE2-AEC1-4777-949C-50917EDCECB1@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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
https://git.vuxu.org/mirror/zsh/
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).