Bug 61539 - The race condition in linuxthreads
The race condition in linuxthreads
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks: 61901 67218 79579
  Show dependency treegraph
 
Reported: 2002-03-21 02:28 EST by hjl
Modified: 2007-04-18 12:41 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-23 18:40:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
A simple patch (629 bytes, patch)
2002-03-21 02:29 EST, hjl
no flags Details | Diff
A patch with spinlock (2.45 KB, patch)
2002-03-21 03:16 EST, hjl
no flags Details | Diff

  None (edit)
Description hjl 2002-03-21 02:28:06 EST
There is a race condition between __pthread_manager_adjust_prio
called from pthread_setschedparam and pthread_start_thread on
manager_thread->p_priority. When a thread is calling
pthread_setschedparam, the new thread may inherit SCHED_FIFO from
the manager thread. That is

Thread A calls pthread_setschedparam
  calls __pthread_manager_adjust_prio
    calls __sched_setscheduler (SCHED_FIFO) on the manager thread.
The main thread calls pthread_create
  The manager threads calls pthread_start_thread. It does

        if (manager_thread->p_priority > 0)
          __sched_setscheduler (SCHED_OTHER)

Since manager_thread->p_priority may not be changed by
__pthread_manager_adjust_prio yet, the new thread may inherit
SCHED_FIFO. Here is a patch. the worst case is pthread_start_thread
may call __sched_setscheduler (SCHED_OTHER) before 
__sched_setscheduler (SCHED_FIFO) is called on the manager thread.
Comment 1 hjl 2002-03-21 02:29:50 EST
Created attachment 49328 [details]
A simple patch
Comment 2 hjl 2002-03-21 02:32:02 EST
I don't know if a spinlock for manager_thread->p_priority
is a better fix. Also we need to check if there are any other
race conditions like that for other manager_thread fields.
Comment 3 hjl 2002-03-21 03:16:31 EST
Created attachment 49329 [details]
A patch with spinlock
Comment 4 hjl 2002-03-21 03:17:22 EST
I uploaded another patch with spinlock.
Comment 5 Ulrich Drepper 2003-04-23 18:40:31 EDT
I've explained a few times on the libc lists that the patches aren't adequate. 
And probably no userlevel solution can be adequate.  But this is all pointless
now.  LinuxThreads stays as it is, correct or not.  I'm closing the bug therefore.

Note You need to log in before you can comment on or make changes to this bug.