zsh-workers
 help / color / mirror / code / Atom feed
From: zsugabubus <zsugabubus@national.shitposting.agency>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] malloc inside signal handler
Date: Sat, 31 Jul 2021 22:25:47 +0200	[thread overview]
Message-ID: <20210731202547.yxzvwevxvy22ywm3@localhost> (raw)
In-Reply-To: <CAH+w=7YaKruWbbROqsi09KVNyv38wWgk8c+6wwk4NL4x64n=UQ@mail.gmail.com>

On Fri, Jul 30, 2021 at 06:33:08PM -0700, Bart Schaefer wrote:
> Under what circumstances are you generating this error?

I had the crash with the following command:

    zsh -c ". hashes.zsh; print ~dir"

that was being executed inside $TERMINAL -e so that explains SIGWINCH.

(hashes.zsh contains a few hash -d lines.)

Unfortunately, I could not find any way to reproduce this again, even
though I call it a few hundred times a day.

However, looking at the stack trace it seems straightforward (for me)
what's going on:

shingetline() calls winch_unblock() and dont_queue_signals() so fgetc()
can be interrupted at any time.

$ gdb zsh -ex 'b input.c:153' -ex 'r' -ex 'b adjustwinsize' -ex 'signal SIGWINCH' -ex 'bt'

Just to make sure, it confirms that SIGWINCH can be handled around
fgetc(), maybe during a memory allocation inside it so if
adjustwinsize() also uses malloc() that can be fatal.

-- 
zsugabubus


  reply	other threads:[~2021-07-31 20:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-24 22:50 zsugabubus
2021-07-31  1:33 ` Bart Schaefer
2021-07-31 20:25   ` zsugabubus [this message]
2021-08-17  4:20     ` Bart Schaefer
2021-08-17  8:21       ` Peter Stephenson
2021-08-18 19:27         ` Peter Stephenson
2021-08-26 15:46           ` Peter Stephenson
2021-08-26 15:51             ` Bart Schaefer

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=20210731202547.yxzvwevxvy22ywm3@localhost \
    --to=zsugabubus@national.shitposting.agency \
    --cc=schaefer@brasslantern.com \
    --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).