On Mon, 2020-05-18 at 00:05 +0200, Mark Wielaard wrote: > Hi, > > While trying out -fanalyzer on the bzip2 source code I noticed that > it > did warn about some unsafe calls in the signal handler, but din't > warn > about the exit call: > https://sourceware.org/pipermail/bzip2-devel/2020q2/000107.html > > It was easy to add exit to the async_signal_unsafe_fns, but since > there is a signal safe _exit call (which is what you should use in a > signal handler, so no unsafe calls are made, like to the at_exit > handlers) I also wanted to add a fixit hint. > > The fixit hint is emitted, but it is somewhat hard to see. Is there a > better way to do this for analyzer warnings so that it is a bit more > prominent? > > This is how it currently looks: > > /opt/local/gcc/bin/gcc -g -O2 -fanalyzer -c bzip2.c > bzip2.c: In function ‘mySIGSEGVorSIGBUScatcher’: > bzip2.c:874:4: warning: call to ‘exit’ from within signal handler > [CWE-479] [-Wanalyzer-unsafe-call-within-signal-handler] > 874 | exit(exitValue); > | ^~~~~~~~~~~~~~~ > | _exit > ‘main’: events 1-2 > | > | 1784 | IntNative main ( IntNative argc, Char *argv[] ) > | | ^~~~ > | | | > | | (1) entry to ‘main’ > |...... > | 1800 | smallMode = False; > | | ~~~~~~~~~ > | | | > | | (2) registering ‘mySIGSEGVorSIGBUScatcher’ as signal > handler > |
BTW, it looks like it's using the wrong location for event (2). It ought to be showing a call to "signal", not an assignment. Please can you file a bug about this, and attach the source in question so I can take a look at some point. Thanks Dave > event 3 > | > |cc1: > | (3): later on, when the signal is delivered to the process > | > +--> ‘mySIGSEGVorSIGBUScatcher’: events 4-5 > | > | 816 | void mySIGSEGVorSIGBUScatcher ( IntNative n ) > | | ^~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | | (4) entry to ‘mySIGSEGVorSIGBUScatcher’ > |...... > | 874 | exit(exitValue); > | | ~~~~~~~~~~~~~~~ > | | | > | | (5) call to ‘exit’ from within signal handler > | > > Thanks, > > Mark >