Home > pthread cond timedwait error > pthread_cond_timedwait error code 22

Pthread_cond_timedwait Error Code 22


false positive Summary pthread_cond_timedwait failure leads to not-locked

Pthread_cond_timedwait Return Value

false positive Status VERIFIED FIXED Product: valgrind Classification: Unclassified pthread_cond_timedwait example Component: helgrind Version: 3.6.0 Platform: Ubuntu Packages Linux Importance: NOR normal (vote) TargetMilestone: ---


Assigned To: Julian Seward URL: Keywords: Depends on: Blocks: Show dependency tree /graph Reported: 2011-04-28 13:49 UTC by Magnus Reftel Modified: 2011-11-17 12:11 UTC (History) CC List: 0 users See Also: Latest Commit: Version Fixed In: Description Magnus Reftel 2011-04-28 13:49:53 UTC If the abstime argument to pthread_cond_timedwait is invalid (e.g. nsec is greater than 1000000000), then a subsequent release of the mutex involved is incorrectly reported as an error. See testcase below. ~/src/helgrindbug$ cat fail.c #include #include #include #include int main() { struct timespec abstime; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; assert(clock_gettime(CLOCK_REALTIME, &abstime)==0); abstime.tv_nsec += 1000000000; assert(pthread_mutex_lock(&mutex)==0); assert(pthread_cond_timedwait(&cond, &mutex, &abstime)==EINVAL); assert(pthread_mutex_unlock(&mutex)==0); return 0; } ~/src/helgrindbug$ valgrind --tool=helgrind ./fail ==23067== Helgrind, a thread error detector ==23067== Copyright (C) 2007-2010, and GNU GPL'd, by OpenWorks LLP et al. ==23067== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info ==23067== Command: ./fail ==23067== ==23067== Thread #1 is the program's root thread ==23067== ==23067== Thread #1's call to pthread_cond_timedwait failed ==23067== with error code 22 (EINVAL: Invalid argument) ==23067== at 0x4C2C46F: pthread_cond_timedwait_WRK (hg_intercepts.c:774) ==23067== by 0x4C2C48E: pthread_cond_timedwait@* (hg_intercepts.c:787) ==23067== by 0x400806: main (in /home/qrefmag/src/helgrindbug/fail) ==23067== ==23067== Thread #1 unlocked a not-locked lock at 0x7FF000440 ==23067== at 0x4C29B94: pthre

and ensure that your hosting provider's database server is running. For more help, see the handbook, or contact your hosting provider.The mysqli error was: Too many connections.

wait on a condition SYNOPSIS [THR] [Option Start] #include http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_cond_timedwait.html <pthread.h>

int pthread_cond_timedwait(pthread_cond_t *restrict
pthread_mutex_t *restrict
const struct timespec *restrict
int pthread_cond_wait(pthread_cond_t *restrict
pthread_mutex_t *restrict
mutex); [Option End] DESCRIPTION The pthread_cond_timedwait() and pthread_cond_wait() functions shall block on a condition variable. They shall be called with pthread_cond_timedwait error mutex locked by the calling thread or undefined behavior results. These functions atomically release mutex and cause the calling thread to block on the condition variable cond; atomically here means "atomically with respect to access by another thread to the mutex and then the condition variable". That is, if pthread_cond_timedwait error code another thread is able to acquire the mutex after the about-to-block thread has released it, then a subsequent call to pthread_cond_broadcast() or pthread_cond_signal() in that thread shall behave as if it were issued after the about-to-block thread has blocked. Upon successful return, the mutex shall have been locked and shall be owned by the calling thread. When using condition variables there is always a Boolean predicate involving shared variables associated with each condition wait that is true if the thread should proceed. Spurious wakeups from the pthread_cond_timedwait() or pthread_cond_wait() functions may occur. Since the return from pthread_cond_timedwait() or pthread_cond_wait() does not imply anything about the value of this predicate, the predicate should be re-evaluated upon such return. When a thread waits on a condition variable, having specified a particular mutex to either the pthread_cond_timedwait() or the pthread_cond_wait() operation, a dynamic binding is fo


Related content

No related pages.