[PATCH] Don't call unsafe functions from SIGSEGV/SIGBUS signal handler.

Mark Wielaard mark@klomp.org
Sat May 23 16:35:36 GMT 2020


Hi,

On Sun, 2020-05-17 at 21:09 +0200, Mark Wielaard wrote:
> GCC10 -fanalyzer notices that we try to call functions that are not
> signal safe from our fatal signal handler:
> 
> bzip2.c: In function ‘mySIGSEGVorSIGBUScatcher’:
> bzip2.c:819:7: warning: call to ‘fprintf’ from within signal handler
>                [CWE-479] [-Wanalyzer-unsafe-call-within-signal-
> handler]
> 
> It also notices we then call showFileNames and cleanupAndFail which
> also call possibly not signal safe functions.
> 
> Just write out the error message directly to STDERR and exit without
> trying to clean up any files.

I pushed this to master now.

Note GCC11 will also warn about the previous usage of exit() (which is
also not signal safe and was replaced with _exit() in this patch):
https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546189.html

Cheers,

Mark


More information about the Bzip2-devel mailing list