Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 38057088b7cebb671c8dbe398a6c46cb9de087b2
Ticket: 3048057fffffffffffffffffffffffffffffffff
race in Tcl_MutexLock ?
User & Date: dgp on 2010-08-18 20:20:45
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    A colleague is debugging thread issues in
    a program that uses Tcl's collection of 
    thread-related routines as a cross-platform
    threading library.  When using the Google
    tool "ThreadSanitizer" to examine the program
    
    http://code.google.com/p/data-race-test/wiki/ThreadSanitizer
    
    a report comes back claiming that the double check
    locking scheme in Tcl_MutexLock is susceptible to a
    race condition.  Some links on the subject:
    
    http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
    http://bartoszmilewski.wordpress.com/2008/11/05/who-ordered-memory-fences-on-an-x86/
    
    The output from ThreadSanitizer:
    
    ==6800== INFO: T2 has been created by T0. Use --announce-threads to see the creation stack.
    ==6800== INFO: T3 has been created by T0. Use --announce-threads to see the creation stack.
    ==6800== WARNING: Possible data race during read of size 8 at 0x7FFEFF1D68: {{{
    ==6800==    T3 (L{}):
    ==6800==     #0  Tcl_MutexLock /local/home/donahue/ftp/tmp/tcl8.5.8/unix/../unix/tclUnixThrd.c:519
    ==6800==     #1  Oxs_Mutex::Lock() /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.h:76
    ==6800==     #2  Oxs_ThreadControl::Lock() /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.h:166
    ==6800==     #3  _Oxs_ThreadBush_main(void*) /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.cc:652
    ==6800==     #4  NewThreadProc /local/home/donahue/ftp/tmp/tcl8.5.8/unix/../generic/tclEvent.c:1487
    ==6800==     #5  ThreadSanitizerStartThread /b/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:609
    ==6800==   Concurrent write(s) happened at (OR AFTER) these points:
    ==6800==    T2 (L{L3}):
    ==6800==     #0  Tcl_MutexLock /local/home/donahue/ftp/tmp/tcl8.5.8/unix/../unix/tclUnixThrd.c:528
    ==6800==     #1  Oxs_Mutex::Lock() /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.h:76
    ==6800==     #2  Oxs_ThreadControl::Lock() /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.h:166
    ==6800==     #3  _Oxs_ThreadBush_main(void*) /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.cc:652
    ==6800==     #4  NewThreadProc /local/home/donahue/ftp/tmp/tcl8.5.8/unix/../generic/tclEvent.c:1487
    ==6800==     #5  ThreadSanitizerStartThread /b/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:609
    ==6800==   Location 0x7FFEFF1D68 is 62096 bytes inside T0's stack [0x7FFE000FF8,0x7FFF000FF8]
    ==6800==   Locks involved in this report (reporting last lock sites): {L3}
    ==6800==    L3 (0x5334900)
    ==6800==     #0  pthread_mutex_lock /b/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:850
    ==6800==     #1  Tcl_MutexLock /local/home/donahue/ftp/tmp/tcl8.5.8/unix/../unix/tclUnixThrd.c:520
    ==6800==     #2  Oxs_Mutex::Lock() /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.h:76
    ==6800==     #3  Oxs_ThreadControl::Lock() /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.h:166
    ==6800==     #4  _Oxs_ThreadBush_main(void*) /local/home/donahue/nobackup/tmp/valgrind/oommf/app/oxs/base/oxsthread.cc:652
    ==6800==     #5  NewThreadProc /local/home/donahue/ftp/tmp/tcl8.5.8/unix/../generic/tclEvent.c:1487
    ==6800==     #6  ThreadSanitizerStartThread /b/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:609
    ==6800==    Race verifier data: 0x50F364A,0x50F3692
    ==6800== }}}
    
    I have a vague sense that this is a known issue already,
    and the threading gurus in the Tcl world have some reason
    to believe it's not a real problem.  Perhaps the only new
    issue here is the existence of a tool that will point a
    finger of blame at us, and whether there's anyhting that
    can or should be done about that.
    
    
    
  4. foundin changed to: "obsolete: 8.5.8"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "dgp"
  10. subsystem changed to: "49. Threading"
  11. title changed to: "race in Tcl_MutexLock ?"
  12. type changed to: "Bug"