Mercurial > cpython-lru_cache-weakref
comparison Python/thread_pthread.h @ 61184:4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
http://code.google.com/p/data-race-test/wiki/ThreadSanitizer is a dynamic data
race detector that runs on top of valgrind. With this patch, the binaries at
http://code.google.com/p/data-race-test/wiki/ThreadSanitizer#Binaries pass many
but not all of the Python tests. All of regrtest still passes outside of tsan.
I've implemented part of the C1x atomic types so that we can explicitly mark
variables that are used across threads, and get defined behavior as compilers
advance.
I've added tsan's client header and implementation to the codebase in
dynamic_annotations.{h,c} (docs at
http://code.google.com/p/data-race-test/wiki/DynamicAnnotations).
Unfortunately, I haven't been able to get helgrind and drd to give sensible
error messages, even when I use their client annotations, so I'm not supporting
them.
| author | Jeffrey Yasskin <jyasskin@gmail.com> |
|---|---|
| date | Mon, 03 May 2010 19:29:34 +0000 |
| parents | 01d1fd775d16 |
| children | cab14be0ada1 |
comparison
equal
deleted
inserted
replaced
| 61182:81cef5b74f1a | 61184:4fd3ab5fa71d |
|---|---|
| 395 lock->locked = 0; | 395 lock->locked = 0; |
| 396 | 396 |
| 397 status = pthread_mutex_init(&lock->mut, | 397 status = pthread_mutex_init(&lock->mut, |
| 398 pthread_mutexattr_default); | 398 pthread_mutexattr_default); |
| 399 CHECK_STATUS("pthread_mutex_init"); | 399 CHECK_STATUS("pthread_mutex_init"); |
| 400 /* Mark the pthread mutex underlying a Python mutex as | |
| 401 pure happens-before. We can't simply mark the | |
| 402 Python-level mutex as a mutex because it can be | |
| 403 acquired and released in different threads, which | |
| 404 will cause errors. */ | |
| 405 _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(&lock->mut); | |
| 400 | 406 |
| 401 status = pthread_cond_init(&lock->lock_released, | 407 status = pthread_cond_init(&lock->lock_released, |
| 402 pthread_condattr_default); | 408 pthread_condattr_default); |
| 403 CHECK_STATUS("pthread_cond_init"); | 409 CHECK_STATUS("pthread_cond_init"); |
| 404 | 410 |
