[rtems commit] posix: fix race condition between pthread_create and capture engine

Gedare Bloom gedare at rtems.org
Fri Apr 11 19:32:40 UTC 2014


Module:    rtems
Branch:    4.10
Commit:    907cfb1e2fa46fed0d0812dc4295d91bfbe01892
Changeset: http://git.rtems.org/rtems/commit/?id=907cfb1e2fa46fed0d0812dc4295d91bfbe01892

Author:    Till Strauman <strauman at slac.stanford.edu>
Date:      Tue Dec 17 17:42:53 2013 -0600

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.

---

 cpukit/posix/src/pthreadcreate.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index c5ca86d..054261b 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -198,6 +198,8 @@ int pthread_create(
    */
   the_thread->do_post_task_switch_extension = true;
 
+  _Thread_Disable_dispatch();
+
   /*
    *  POSIX threads are allocated and started in one operation.
    */
@@ -217,6 +219,7 @@ int pthread_create(
      *        thread while we are creating it.
      */
     if ( !status ) {
+      _Thread_Enable_dispatch();
       _POSIX_Threads_Free( the_thread );
       _RTEMS_Unlock_allocator();
       return EINVAL;
@@ -230,6 +233,8 @@ int pthread_create(
     );
   }
 
+  _Thread_Enable_dispatch();
+
   /*
    *  Return the id and indicate we successfully created the thread
    */




More information about the vc mailing list