[RTEMS Project] #2130: Race condition in nanosleep()

RTEMS trac trac at rtems.org
Thu Dec 18 12:28:21 UTC 2014


#2130: Race condition in nanosleep()
-----------------------------+----------------------------
 Reporter:  sebastian.huber  |       Owner:  joel.sherrill
     Type:  defect           |      Status:  new
 Priority:  low              |   Milestone:  5.0
Component:  cpukit           |     Version:  4.11
 Severity:  critical         |  Resolution:
 Keywords:                   |
-----------------------------+----------------------------
Changes (by sebastian.huber):

 * priority:  normal => low
 * severity:  normal => critical
 * milestone:  4.11 => 5.0


Old description:

> int nanosleep(
>   const struct timespec  *rqtp,
>   struct timespec        *rmtp
> )
> {
> [...]
>   /*
>    *  Block for the desired amount of time
>    */
>   _Thread_Disable_dispatch();
>     executing = _Thread_Executing;
>     _Thread_Set_state(
>       executing,
>       STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL
>     );
>
>     <-- A signal at this point will destroy the watchdog chain and the
> system is corrupt.
>
>     _Watchdog_Initialize(
>       &executing->Timer,
>       _Thread_Delay_ended,
>       executing->Object.id,
>       NULL
>     );
>     _Watchdog_Insert_ticks( &executing->Timer, ticks );
>   _Thread_Enable_dispatch();
> [...]

New description:

 int nanosleep(
   const struct timespec  *rqtp,
   struct timespec        *rmtp
 )
 {
 [...]
   /*
    *  Block for the desired amount of time
    */
   _Thread_Disable_dispatch();
     executing = _Thread_Executing;
     _Thread_Set_state(
       executing,
       STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL
     );

     <-- A signal at this point will destroy the watchdog chain and the
 system is corrupt.

     _Watchdog_Initialize(
       &executing->Timer,
       _Thread_Delay_ended,
       executing->Object.id,
       NULL
     );
     _Watchdog_Insert_ticks( &executing->Timer, ticks );
   _Thread_Enable_dispatch();
 [...]

--

--
Ticket URL: <http://devel.rtems.org/ticket/2130#comment:3>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list