|
From: Martin H. <mar...@ci...> - 2011-07-28 14:55:56
|
Hi all, when running a program under Helgrind, it has suddenly terminated with the following output to console: Helgrind: hg_main.c:2298 (evh__HG_PTHREAD_COND_WAIT_POST): Assertion 'cvi->nWaiters > 0' failed. ==17637== at 0x3801E565: report_and_quit (m_libcassert.c:191) ==17637== by 0x3801E737: vgPlain_assert_fail (m_libcassert.c:265) ==17637== by 0x380088EA: evh__HG_PTHREAD_COND_WAIT_POST (hg_main.c:2298) ==17637== by 0x3800A56E: hg_handle_client_request (hg_main.c:4282) ==17637== by 0x3805E699: vgPlain_scheduler (scheduler.c:1560) ==17637== by 0x3808BE44: run_a_thread_NORETURN (syswrap-linux.c:91) ==17637== by 0x3808C102: vgModuleLocal_start_thread_NORETURN (syswrap-linux.c:222) ==17637== by 0x3808F128: ??? (in /usr/lib/valgrind/helgrind-x86-linux) Do you have an idea what this could be caused by? I am using Valgrind version valgrind-3.6.0.SVN-Debian on Ubuntu 10.04 32bit (kernel version 2.6.32-32-generic). Thanks, Martin Heller |
|
From: WAROQUIERS P. <phi...@eu...> - 2011-07-28 15:49:25
|
>Helgrind: hg_main.c:2298 (evh__HG_PTHREAD_COND_WAIT_POST): Assertion >'cvi->nWaiters > 0' failed. It looks like a bug in valgrind/helgrind. As Julian has improved a lot helgrind in 3.7.0, an easy thing to try is to get the last version from svn, recompile and see if it works better. See http://www.valgrind.org/downloads/repository.html Section 'The Current (3.0 and later) ...' Philippe ____ This message and any files transmitted with it are legally privileged and intended for the sole use of the individual(s) or entity to whom they are addressed. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful. Nothing in this e-mail message amounts to a contractual or legal commitment on the part of EUROCONTROL, unless it is confirmed by appropriately signed hard copy. Any views expressed in this message are those of the sender. |
|
From: Martin H. <mar...@ci...> - 2011-07-29 13:19:22
|
Thanks for the answer. I have downloaded Valgrind 3.7.0 from the SVN and it gives the same error in the same situation: Helgrind: hg_main.c:2323 (evh__HG_PTHREAD_COND_WAIT_POST): Assertion 'cvi->nWaiters > 0' failed. ==27555== at 0x3802228D: report_and_quit (m_libcassert.c:210) ==27555== by 0x38022457: vgPlain_assert_fail (m_libcassert.c:284) ==27555== by 0x38008FDA: evh__HG_PTHREAD_COND_WAIT_POST (hg_main.c:2323) ==27555== by 0x3800BCDD: hg_handle_client_request (hg_main.c:4566) ==27555== by 0x3806CBA9: vgPlain_scheduler (scheduler.c:1682) ==27555== by 0x3809AFF6: run_a_thread_NORETURN (syswrap-linux.c:98) ==27555== by 0x3809B352: vgModuleLocal_start_thread_NORETURN (syswrap-linux.c:259) ==27555== by 0x3809E428: ??? (in /usr/local/lib/valgrind/helgrind-x86-linux) Martin Heller |
|
From: Martin H. <mar...@ci...> - 2011-08-19 15:42:29
|
Hi all,
I have had some luck finding the error which caused this Helgrind
assertion to fail. Not surprisingly it was an error in the debugged
program's code.
A pthread condition variable was being destroyed just after being
signalled, before the other thread would return from the wait function.
Short code reproducing the error is given below.
// CODE BEGIN
#include <iostream>
#include <pthread.h>
pthread_mutex_t mutex;
pthread_cond_t cond;
pthread_t thread;
bool ready = false;
void *ThreadFunction(void *ptr) {
pthread_mutex_lock(&mutex);
ready = true;
pthread_cond_signal(&cond);
pthread_cond_destroy(&cond); // ERROR!!!
pthread_mutex_unlock(&mutex);
return NULL;
}
int main() {
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cond, NULL);
pthread_mutex_lock(&mutex);
pthread_create(&thread, NULL, ThreadFunction, (void*) NULL);
while (!ready) { // to insure ourselves against spurious wakeups
pthread_cond_wait(&cond, &mutex);
}
pthread_mutex_unlock(&mutex);
pthread_join(thread, NULL);
pthread_mutex_destroy(&mutex);
std::cout << "finished" << std::endl;
return 0;
}
// CODE END
Martin Heller
|