DRD: a thread error detector
• Calling
pthread_cond_wait
on a mutex that is not locked, that is locked by another thread or that has been
locked recursively.
• Associating two different mutexes with a condition variable through
pthread_cond_wait
.
• Destruction or deallocation of a condition variable that is being waited upon.
• Destruction or deallocation of a locked reader-writer synchronization object.
• Attempts to unlock a reader-writer synchronization object that was not locked by the calling thread.
• Attempts to recursively lock a reader-writer synchronization object exclusively.
• Attempts to pass the address of a user-defined reader-writer synchronization object to a POSIX threads function.
• Attempts to pass the address of a POSIX reader-writer synchronization object to one of the annotations for user-
defined reader-writer synchronization objects.
• Reinitialization of a mutex, condition variable, reader-writer lock, semaphore or barrier.
• Destruction or deallocation of a semaphore or barrier that is being waited upon.
• Missing synchronization between barrier wait and barrier destruction.
• Exiting a thread without first unlocking the spinlocks, mutexes or reader-writer synchronization objects that were
locked by that thread.
• Passing an invalid thread ID to
pthread_join
or
pthread_cancel
.
8.2.5. Client Requests
Just as for other Valgrind tools it is possible to let a client program interact with the DRD tool through client requests.
In addition to the client requests several macros have been defined that allow to use the client requests in a convenient
way.
The interface between client programs and the DRD tool is defined in the header file
<valgrind/drd.h>
. The
available macros and client requests are:
• The macro
DRD_GET_VALGRIND_THREADID
and the corresponding client request
VG_USERREQ__DRD_GET_VALGRIND_THREAD_ID
.
Query the thread ID that has been assigned by the Valgrind core to the thread executing this client request. Valgrind’s
thread ID’s start at one and are recycled in case a thread stops.
• The macro
DRD_GET_DRD_THREADID
and the corresponding client request
VG_USERREQ__DRD_GET_DRD_THREAD_ID
.
Query the thread ID that has been assigned by DRD to the thread executing this client request. These are the thread
ID’s reported by DRD in data race reports and in trace messages. DRD’s thread ID’s start at one and are never
recycled.
• The macros
DRD_IGNORE_VAR(x)
,
ANNOTATE_TRACE_MEMORY(&x)
and the corresponding client request
VG_USERREQ__DRD_START_SUPPRESSION
. Some applications contain intentional races. There exist e.g.
applications where the same value is assigned to a shared variable from two different threads. It may be more
convenient to suppress such races than to solve these. This client request allows to suppress such races.
128