Hi,

I've found a small bug in helgrind:

$ cat tests/rwlock_bug.c
#define _GNU_SOURCE 1
#include <stdio.h>
#include <pthread.h>
#include <assert.h>
int main ( void )
{
  pthread_rwlock_t rwl;
  pthread_rwlock_init( &rwl, NULL );
  pthread_rwlock_wrlock( &rwl );
  // no unlock!
  pthread_rwlock_destroy( &rwl );
  return 0;
}
$ gcc -g  tests/rwlock_bug.c -lpthread
$ ../Inst/bin/valgrind --tool=helgrind ./a.out
==13027== Thread #1: pthread_rwlock_destroy of a locked mutex
==13027==    at 0x47A8A76: pthread_rwlock_destroy (hg_intercepts.c:778)
DIR:/home/kcc/valgrind/helgrind
==13027==    by 0x8048474: main (rwlock_bug.c:11)
DIR:/home/kcc/valgrind/helgrind/tests
Helgrind: hg_main.c:6272 (evh__HG_PTHREAD_RWLOCK_DESTROY_PRE): Assertion
'is_sane_LockN(lk)' failed.
==13027==    at 0x3801C206: report_and_quit (m_libcassert.c:140)
DIR:/home/kcc/valgrind/coregrind
==13027==    by 0x3801C06A: vgPlain_assert_fail (m_libcassert.c:200)
DIR:/home/kcc/valgrind/coregrind
==13027==    by 0x38014D86: evh__HG_PTHREAD_RWLOCK_DESTROY_PRE
(hg_main.c:6272) DIR:/home/kcc/valgrind/helgrind
==13027==    by 0x38016A98: hg_handle_client_request (hg_main.c:7627)
DIR:/home/kcc/valgrind/helgrind
==13027==    by 0x38036D03: do_client_request (scheduler.c:1380)
DIR:/home/kcc/valgrind/coregrind/m_scheduler
==13027==    by 0x38037D5D: vgPlain_scheduler (scheduler.c:979)
DIR:/home/kcc/valgrind/coregrind/m_scheduler
==13027==    by 0x3803AD03: run_a_thread_NORETURN (syswrap-linux.c:87)
DIR:/home/kcc/valgrind/coregrind/m_syswrap


The fix is probably to put lk->acquired_at = NULL; somewhere in
evh__HG_PTHREAD_RWLOCK_DESTROY_PRE.


Thanks,

--kcc
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to