Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: signal() anomaly |
| Date | 2012-08-01 18:14 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <5019AA3D.4070403@verizon.net> (permalink) |
| References | <jv9e9e$bj3$1@speranza.aioe.org> <jv9l8p$1u2$1@blue-new.rahul.net> <jvbu80$pu5$1@speranza.aioe.org> <50198480.3040408@verizon.net> <jvc4kl$aus$1@speranza.aioe.org> |
On 08/01/2012 04:47 PM, hip cat wrote: > On Wed, 01 Aug 2012 15:33:20 -0400, James Kuyper wrote: ... >> Well, as "Nobody" has already pointed out, that's not an option. Using >> SIG_IGN for this has undefined behavior. So does registering your own >> SIGSEGV "handler" that doesn't bother to actually do anything, and >> simply returns. Therefore, you're going to have to either insert the >> null checks, or let the program abort() - your choice. > > Word Jim, > > I think Eric was right on the money asking about the return value. If the > signal() call returns success, but the "ignore" is ignored, I say that's > a bug in the C library. I think I'll file a bug report against glibc. The C standard specifies that dereferencing a null pointer has undefined behavior. One of the possibilities allowed by that fact is that a SIGSEGV signal is raised, but the standard does not require that it be raised. Whether or not that signal is raised, and regardless of whether the SIGSEGV handler has been set to SIG_IGN, SIG_DFL, or an actual signal handler, the behavior of your program remains undefined by the C standard. It doesn't matter what the signal handler actually does, the behavior of your program became undefined as soon as it dereferenced a null pointer. The POSIX standard does specify that a SIGSEGV signal be raised, but specifies that the behavior of your program is undefined if that signal is ignored, or if the signal handler returns. "undefined behavior" means that anything is permitted, including aborting your program. Your program aborted, which is one of the permitted behaviors. On what grounds are you going to report a bug? What requirement of any standard is violated by the fact that your program aborted?
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
signal() anomaly hip cat <nospam@nospam.com> - 2012-07-31 20:13 +0000
Re: signal() anomaly Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-31 16:35 -0400
Re: signal() anomaly hip cat <nospam@nospam.com> - 2012-08-01 18:59 +0000
Re: signal() anomaly Nick Bowler <nbowler@draconx.ca> - 2012-08-01 20:14 +0000
Re: signal() anomaly falk@rahul.net (Edward A. Falk) - 2012-07-31 22:12 +0000
Re: signal() anomaly hip cat <nospam@nospam.com> - 2012-08-01 18:58 +0000
Re: signal() anomaly James Kuyper <jameskuyper@verizon.net> - 2012-08-01 15:33 -0400
Re: signal() anomaly hip cat <nospam@nospam.com> - 2012-08-01 20:47 +0000
Re: signal() anomaly Paul <nospam@needed.com> - 2012-08-01 17:34 -0400
Re: signal() anomaly Johann Klammer <klammerj@NOSPAM.a1.net> - 2012-08-02 06:34 +0200
Re: signal() anomaly Paul <nospam@needed.com> - 2012-08-02 07:10 -0400
Re: signal() anomaly Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-01 18:07 -0400
Re: signal() anomaly Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-02 00:15 +0100
Re: signal() anomaly Nick Bowler <nbowler@draconx.ca> - 2012-08-02 00:05 +0000
Re: signal() anomaly Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-02 02:47 +0100
Re: signal() anomaly James Kuyper <jameskuyper@verizon.net> - 2012-08-01 18:13 -0400
Re: signal() anomaly James Kuyper <jameskuyper@verizon.net> - 2012-08-01 18:14 -0400
Re: signal() anomaly Nobody <nobody@nowhere.com> - 2012-08-02 12:52 +0100
Re: signal() anomaly Angel <angel+news@spamcop.net> - 2012-08-01 19:41 +0000
Re: signal() anomaly Kenneth Brody <kenbrody@spamcop.net> - 2012-08-01 16:16 -0400
Re: signal() anomaly Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-01 16:33 -0400
Re: signal() anomaly Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-02 00:22 +0100
Re: signal() anomaly Stephen Sprunk <stephen@sprunk.org> - 2012-08-02 00:55 -0500
Re: signal() anomaly Ike Naar <ike@sverige.freeshell.org> - 2012-08-02 07:01 +0000
Re: signal() anomaly Öö Tiib <ootiib@hot.ee> - 2012-09-08 20:53 -0700
Re: signal() anomaly Nobody <nobody@nowhere.com> - 2012-08-01 18:06 +0100
Re: signal() anomaly Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 13:44 -0700
Re: signal() anomaly Kleuske <kleuske@nowhere.net> - 2012-08-02 20:52 +0000
csiph-web