Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-22 Thread Mark Wielaard
On Thu, May 21, 2020 at 09:05:09AM -0400, David Malcolm wrote: > So the above should read something like: > > + exit(1); /* { dg-warning "call to 'exit' from within signal handler" > "warning" } */ > + /* { dg-message "note: '_exit' is a possible signal-safe alternative for > 'exit'" "replacem

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-21 Thread David Malcolm via Gcc-patches
On Thu, 2020-05-21 at 00:48 +0200, Mark Wielaard wrote: > Hi, > > On Mon, May 18, 2020 at 07:30:58PM -0400, Marek Polacek wrote: > > > + /* Returns a replacement function as text if it > > > exists. Currently > > > + only "exit" has a signal-safe replacement "_exit", which > > > does > > > +

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-20 Thread Mark Wielaard
Hi, On Mon, May 18, 2020 at 07:30:58PM -0400, Marek Polacek wrote: > > + /* Returns a replacement function as text if it exists. Currently > > + only "exit" has a signal-safe replacement "_exit", which does > > + slightly less, but can be used in a signal handler. */ > > + const char *

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-18 Thread Marek Polacek via Gcc-patches
On Tue, May 19, 2020 at 01:19:13AM +0200, Mark Wielaard wrote: > On Mon, May 18, 2020 at 05:24:58PM +0200, Mark Wielaard wrote: > > On Mon, May 18, 2020 at 11:09:18AM -0400, David Malcolm wrote: > > > Overall, I like it, but it looks like there's a problem with the > > > location of the fix-it hint

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-18 Thread Mark Wielaard
On Mon, May 18, 2020 at 05:24:58PM +0200, Mark Wielaard wrote: > On Mon, May 18, 2020 at 11:09:18AM -0400, David Malcolm wrote: > > Overall, I like it, but it looks like there's a problem with the > > location of the fix-it hint: it looks like it might be replacing the > > whole of the underlined s

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-18 Thread Mark Wielaard
Hi David, On Mon, May 18, 2020 at 11:09:18AM -0400, David Malcolm wrote: > On Mon, 2020-05-18 at 16:47 +0200, Mark Wielaard wrote: > > On Mon, May 18, 2020 at 08:45:36AM -0400, David Malcolm wrote: > > > Also, m_unsafe_fndecl is a field of signal_unsafe_call, so we can > > > delay > > > calling re

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-18 Thread David Malcolm via Gcc-patches
On Mon, 2020-05-18 at 16:47 +0200, Mark Wielaard wrote: > Hi David, > > On Mon, May 18, 2020 at 08:45:36AM -0400, David Malcolm wrote: > > Also, m_unsafe_fndecl is a field of signal_unsafe_call, so we can > > delay > > calling replacement_fn until inside signal_unsafe_call::emit, after > > the > >

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-18 Thread Mark Wielaard
Hi David, On Mon, May 18, 2020 at 08:45:36AM -0400, David Malcolm wrote: > Also, m_unsafe_fndecl is a field of signal_unsafe_call, so we can delay > calling replacement_fn until inside signal_unsafe_call::emit, after the > warning has been emitted. > > It could even become a member function of si

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-18 Thread Mark Wielaard
Hi David, On Sun, 2020-05-17 at 18:53 -0400, David Malcolm wrote: > 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

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-18 Thread David Malcolm via Gcc-patches
On Sun, 2020-05-17 at 18:42 -0400, David Malcolm via Gcc-patches wrote: > On Sun, 2020-05-17 at 18:39 -0400, David Malcolm via Gcc-patches > wrote: > > On Mon, 2020-05-18 at 00:05 +0200, Mark Wielaard wrote: > > [...snip...] > > > How about something like this (though I even haven't checked if it

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-17 Thread David Malcolm via Gcc-patches
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.

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-17 Thread David Malcolm via Gcc-patches
On Sun, 2020-05-17 at 18:39 -0400, David Malcolm via Gcc-patches wrote: > On Mon, 2020-05-18 at 00:05 +0200, Mark Wielaard wrote: [...snip...] > How about something like this (though I even haven't checked if it > compiles, and am not 100% sure what the wording should be): > > bool emit (rich_

Re: [RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-17 Thread David Malcolm via Gcc-patches
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, Great. > but din't warn > about the exit call: > https://sourceware.org/pipermail/bzip2-devel/2020

[RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

2020-05-17 Thread Mark Wielaard
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