Quantcast

Valgrind: r16342 - in /trunk: NEWS drd/drd_pthread_intercepts.c drd/drd_thread.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Valgrind: r16342 - in /trunk: NEWS drd/drd_pthread_intercepts.c drd/drd_thread.c

svn-2
Author: bart
Date: Tue May  9 05:45:30 2017
New Revision: 16342

Log:
drd: Add support for calling pthread_create() from inside a shared library - bug #356374

Modified:
    trunk/NEWS
    trunk/drd/drd_pthread_intercepts.c
    trunk/drd/drd_thread.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Tue May  9 05:45:30 2017
@@ -172,6 +172,7 @@
 379390  unhandled syscall: mach:70 (host_create_mach_voucher_trap)
 379473  MIPS: add support for rdhwr cycle counter register
 379504  remove TileGX/Linux port
+356374  Assertion 'DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID' failed
 
 Release 3.12.0 (20 October 2016)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Modified: trunk/drd/drd_pthread_intercepts.c
==============================================================================
--- trunk/drd/drd_pthread_intercepts.c (original)
+++ trunk/drd/drd_pthread_intercepts.c Tue May  9 05:45:30 2017
@@ -556,6 +556,14 @@
    assert(thread_args.detachstate == PTHREAD_CREATE_JOINABLE
           || thread_args.detachstate == PTHREAD_CREATE_DETACHED);
 
+   /*
+    * The DRD_(set_pthread_id)() from DRD_(init)() may encounter that
+    * pthread_self() == 0, e.g. when the main program is not linked with the
+    * pthread library and when a pthread_create() call occurs from within a
+    * shared library. Hence call DRD_(set_pthread_id)() again to ensure that
+    * DRD knows the identity of the current thread. See also B.Z. 356374.
+    */
+   DRD_(set_pthread_id)();
    DRD_(entering_pthread_create)();
    CALL_FN_W_WWWW(ret, fn, thread, attr, DRD_(thread_wrapper), &thread_args);
    DRD_(left_pthread_create)();

Modified: trunk/drd/drd_thread.c
==============================================================================
--- trunk/drd/drd_thread.c (original)
+++ trunk/drd/drd_thread.c Tue May  9 05:45:30 2017
@@ -602,8 +602,8 @@
 /**
  * Store the POSIX thread ID for the specified thread.
  *
- * @note This function can be called two times for the same thread -- see also
- * the comment block preceding the pthread_create() wrapper in
+ * @note This function can be called multiple times for the same thread -- see
+ * also the comment block preceding the pthread_create() wrapper in
  * drd_pthread_intercepts.c.
  */
 void DRD_(thread_set_pthreadid)(const DrdThreadId tid, const PThreadId ptid)
@@ -613,6 +613,10 @@
    tl_assert(DRD_(g_threadinfo)[tid].pt_threadid == INVALID_POSIX_THREADID
              || DRD_(g_threadinfo)[tid].pt_threadid == ptid);
    tl_assert(ptid != INVALID_POSIX_THREADID);
+   if (DRD_(g_threadinfo)[tid].posix_thread_exists) {
+      tl_assert(DRD_(g_threadinfo)[tid].pt_threadid == ptid);
+      return;
+   }
    DRD_(g_threadinfo)[tid].posix_thread_exists = True;
    DRD_(g_threadinfo)[tid].pt_threadid         = ptid;
 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers
Loading...