Bug 109432

Summary: Race in pthreads signal handling
Product: [Retired] Red Hat Linux Reporter: Aidan Van Dyk <aidan>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: drepper, fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-01-13 19:25:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Aidan Van Dyk 2003-11-07 20:04:25 UTC
Description of problem:

There is a race of signal handling when a program is linked against
libpthreads (linuxthreads) on redhat linux <= 8.

In linuxthreads/signals.c: __sigaction(...)
    if (__libc_sigaction(sig, newactp, oact) == -1)
       return -1;
    [...]
    if (act)
        __sighandler[sig].old = (arch_sighandler_t) act->sa_handler;

In linuxthreads/sighandler.c: __pthread_sighandler(...)
    CALL_SIGHANDLER(__sighandler[signo].old, signo, ctx);

The problem is when SIG_DFL|SIG_IGN|SIG_ERR is the current handler,
and a new one is being installed.  If the signal comes in after
__pthread_sighandler has been installed, but before
__sighandler[sig].old has been set, then __sighandler[sig].old == -1,
0, or 1, causing segfault when __pthread_sighandler() tries to invoke
it as a function.

A fix would be to make __pthread_sighandler() check it before
following it, or make __sigaction block/unblock the signal around the
race points.

Version-Release number of selected component:
   glibc-2.2.93

Comment 1 Ulrich Drepper 2003-11-07 23:50:27 UTC
Signals and LinuxThreads don't mix.  There will always we problems. 
Even if this specific problem is worked around this doesn't meant he
code will work 100%.

If you want to use signals, use NPTL.  *Nothing* else is supported.

Comment 2 Aidan Van Dyk 2003-11-10 14:08:09 UTC
We are not using threads.  But we use unixODBC, which links against
pthreads to get its mutex for locking.  Just having pthreads linked in
cause it to take strong symbol for sigaction.

So our single-threaded IO dispatching process segfaults regularly on
all redhat versions with glibc-2.2.

Are there NTPL updates available for RH 8 and 7?

Should we be providing our own unixODBC which gives both -lodbc and
-lobdc-nmt?




Comment 3 Ulrich Drepper 2003-11-10 21:50:56 UTC
There will never be official NPTL support for RHL8 or earlier.  If
somebody wants to try it, they are welcome.

Try the test release for the upcoming RHL8 errata at

  ftp://people.redhat.com/drepper/glibc-errata/rhl8

and let us know whether it works or not.

Comment 4 Ulrich Drepper 2003-11-20 17:54:55 UTC
Ping.  Did you try the errata code?  If I don't get any reply I'll
assume the problem is fixed.

Comment 5 Aidan Van Dyk 2003-11-20 17:58:55 UTC
Sorry - I had missed your comments.

Testing...

Comment 6 Ulrich Drepper 2003-11-20 18:04:21 UTC
We wait for info...

Comment 7 Aidan Van Dyk 2003-11-20 18:44:30 UTC
Seems to be working well in a test sandbox.

It has been hammered for 20 minutes (still ongoing).  Prevous max was
around 15 seconds...

Is this errata coming soon?  Any .src.rpms for them?

Comment 8 Aidan Van Dyk 2003-12-10 17:33:34 UTC
Any chances we can get the same pthread_sighandler fix from the
glibc-2.3 based errata into the glibc-2.2 based errata for RH 7?

Something similar to glibc-lt-sigaction.patch?

Comment 9 Aidan Van Dyk 2004-01-13 19:04:25 UTC
*PING*

Comment 10 Ulrich Drepper 2004-01-13 19:25:29 UTC
No RHL7.x version is supported anymore.  Create your own binaries if
you want.