* zsh signal handler is not safe
@ 2019-05-23 6:26 Jeremy Huddleston Sequoia
0 siblings, 0 replies; 1+ messages in thread
From: Jeremy Huddleston Sequoia @ 2019-05-23 6:26 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 902 bytes --]
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.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3433 bytes --]
^ permalink raw reply [flat|nested] 1+ messages in thread
only message in thread, back to index
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
Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers
Newsgroup available over NNTP:
AGPL code for this site: git clone https://public-inbox.org/ public-inbox