Changeset 44c3ffb in rtems


Ignore:
Timestamp:
Dec 17, 2013, 10:59:38 PM (5 years ago)
Author:
Till Strauman <strauman@…>
Branches:
4.9
Children:
b6519e4b
Parents:
765ae93b
git-author:
Till Strauman <strauman@…> (12/17/13 22:59:38)
git-committer:
Gedare Bloom <gedare@…> (04/11/14 19:44:15)
Message:

posix: fix race condition between pthread_create and capture engine

Fix PR 2068:
Reproducable crashes occur when using pthreads and the capture engine
at the same time. 'pthread_create()' is the culprit. It creates a SCORE thread
and then calls Thread_Start( ) without disabling thread-dispatching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/pthreadcreate.c

    r765ae93b r44c3ffb  
    238238   */
    239239
     240  _Thread_Disable_dispatch();
     241
    240242  status = _Thread_Start(
    241243    the_thread,
     
    246248  );
    247249
     250  /*
     251   *  _Thread_Start only fails if the thread was in the incorrect state
     252   * 
     253   *  NOTE: This can only happen if someone slips in and touches the
     254   *        thread while we are creating it.
     255   */
     256
     257  if ( !status ) {
     258    _Thread_Enable_dispatch();
     259    _POSIX_Threads_Free( the_thread );
     260    _RTEMS_Unlock_allocator();
     261    return EINVAL;
     262  }
     263
    248264  if ( schedpolicy == SCHED_SPORADIC ) {
    249265    _Watchdog_Insert_ticks(
     
    253269  }
    254270
    255   /*
    256    *  _Thread_Start only fails if the thread was in the incorrect state
    257    * 
    258    *  NOTE: This can only happen if someone slips in and touches the
    259    *        thread while we are creating it.
    260    */
    261 
    262   if ( !status ) {
    263     _POSIX_Threads_Free( the_thread );
    264     _RTEMS_Unlock_allocator();
    265     return EINVAL;
    266   }
     271  _Thread_Enable_dispatch();
    267272
    268273  /*
Note: See TracChangeset for help on using the changeset viewer.