public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48854] New: signal mask is not restored when exiting signal handler via exception
@ 2011-05-03 14:57 cubbi at cubbi dot org
2011-05-03 15:17 ` [Bug c++/48854] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: cubbi at cubbi dot org @ 2011-05-03 14:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48854
Summary: signal mask is not restored when exiting signal
handler via exception
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: trivial
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: cubbi@cubbi.org
When using -fnon-call-exception to convert a SIGSEGV or SIGFPE to a C++
exception, the straightforward implementation fails to handle the same signal
more than once because it remains masked after the signal handler and the
exception handler have been executed.
While this is reasonable behavior, perhaps it should be briefly mentioned in
the documentation on -fnon-call-exceptions?
Example (compile with -fnon-call-exceptions)
#include <iostream>
#include <stdexcept>
#include <signal.h>
void handler(int signo)
{
std::cerr << "Signal handler called with " << signo << '\n';
// uncomment the following lines to fix the bug
// sigset_t x;
// sigemptyset (&x);
// sigaddset(&x, SIGSEGV);
// sigprocmask(SIG_UNBLOCK, &x, NULL);
throw std::runtime_error("sigsegv");
}
int main()
{
signal(SIGSEGV, handler);
int* invalid_p = NULL;
// first attempt: always works
try{
*invalid_p = 7;
} catch(const std::exception& e)
{
std::cerr << "main() caught " << e.what() << '\n';
}
// second attempt: fails unless uncommented sigprocmask above
try{
*invalid_p = 7;
} catch(const std::exception& e)
{
std::cerr << "main() caught " << e.what() << '\n';
}
}
reproduced using
gcc 3.4.6 (linux x86_64)
gcc 4.4.1 (linux i386)
gcc 4.5.2 (linux x86_64)
gcc 4.6.0 20110325 (linux x86_64)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/48854] signal mask is not restored when exiting signal handler via exception
2011-05-03 14:57 [Bug c++/48854] New: signal mask is not restored when exiting signal handler via exception cubbi at cubbi dot org
@ 2011-05-03 15:17 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-03 15:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48854
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-03 15:16:00 UTC ---
That's standard behavior of signal and not something GCC has influence on.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-03 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-03 14:57 [Bug c++/48854] New: signal mask is not restored when exiting signal handler via exception cubbi at cubbi dot org
2011-05-03 15:17 ` [Bug c++/48854] " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).