This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/15368] New: raise() is not async-signal-safe
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 15 Apr 2013 02:50:54 +0000
- Subject: [Bug nptl/15368] New: raise() is not async-signal-safe
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=15368
Bug #: 15368
Summary: raise() is not async-signal-safe
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: nptl
AssignedTo: unassigned@sourceware.org
ReportedBy: bugdal@aerifal.cx
CC: drepper.fsp@gmail.com
Classification: Unclassified
NPTL's raise() is implemented as a call to pthread_kill(pthread_self(), sig);
this implementation is invalid because pthread_kill is not async-signal-safe.
In particular, if a signal handler forks during raise, the the thread in the
parent could receive the signal twice, once from itself and once from the
child. Or, if raise() is called from a signal handler while fork() has
temporarily modified the tid/pid in TLS, raise() may fail to do anything. Other
incorrect behavior may also be possible too; I have not analyzed the issue in
detail.
The (only) correct implementation of raise() for multi-threaded programs is:
1. Block all signals.
2. Get pid and tid from the kernel via syscalls.
3. Make the tgkill syscall.
4. Restore the old signal mask.
Blocking signals is required to make obtaining the tid/pid atomic with sending
the signal. Anything else fails to meet the async-signal safety requirements.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.