zsh-workers
 help / color / mirror / code / Atom feed
* zsh signal handler is not safe
@ 2019-05-23  6:26 Jeremy Huddleston Sequoia
  0 siblings, 0 replies; only message in thread
From: Jeremy Huddleston Sequoia @ 2019-05-23  6:26 UTC (permalink / raw)
  To: zsh-workers

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

Hi folks,

I wanted to reach out to you and let you know that I've seen some crashes in zsh related to using illegal API from within a signal handler context.  Specifically, you signal handler zhandle() will call zexit() with which in turn calls savehistfile() and lockhistfile() which expectedly does a lot of API calls that are not thread safe (eg: malloc/stdio/etc).

It looks like zexit()'s from_where is set to 1 for the signal handler case, which is causing HFILE_NO_REWRITE to be added to the writeflags passed to savehistfile().  That seems to be designed to avoid the memory allocations from reading in the existing file, but unfortunately we still fail in the call to lockhistfile().

It would be better for your signal handler to set a sentinel that will be checked by the main event loop to trigger the exit and then just get out of the signal handler as soon as possible.

--Jeremy

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3433 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-23  6:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23  6:26 zsh signal handler is not safe Jeremy Huddleston Sequoia

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).