Bug 152728 - Mismatch between VG_(get_running_tid)() and drd's cached thread ID
Summary: Mismatch between VG_(get_running_tid)() and drd's cached thread ID
Status: CLOSED WORKSFORME
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.3 SVN
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-22 20:05 UTC by Bart Van Assche
Modified: 2008-05-11 13:49 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bart Van Assche 2007-11-22 20:05:36 UTC
1. Apply the exp-drd patch posted on November 22, 2007 to the Valgrind sourcecode.
2. Run ./autogen.sh && ./configure && make -s && make -s check
3. Run VALGRIND_LIB=$PWD/.in_place coregrind/valgrind --tool=exp-drd 
exp-drd/tests/sigalrm -d
4. Rerun the same command but now with the option --trace-address=<x>, with <x>
the address on which a data race was reported, e.g.
VALGRIND_LIB=$PWD/.in_place coregrind/valgrind --tool=exp-drd
--trace-address=0x64f4760 exp-drd/tests/sigalrm -d

Expected result: no assertion failures.

Actual result: an assertion failure telling that there was a mismatch between
Valgrind's thread ID and drd's cached thread ID.

Is this a bug in Valgrind's core or a bug in drd ?

Output:

$ VALGRIND_LIB=$PWD/.in_place coregrind/valgrind -v --tool=exp-drd
--trace-address=0x64f4760 exp-drd/tests/sigalrm
==837== drd, a data race detector.
==837== NOTE: This is an Experimental-Class Valgrind Tool.
==837== Copyright (C) 2006-2007, and GNU GPL'd, by Bart Van Assche.
==837== Using LibVEX rev 1734, a library for dynamic binary translation.
==837== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==837== Using valgrind-3.3.0.SVN, a dynamic binary instrumentation framework.
==837== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==837==
--837-- Command line
--837--    exp-drd/tests/sigalrm
--837-- Startup, with flags:
--837--    -v
--837--    --tool=exp-drd
--837--    --trace-address=0x64f4760
--837-- Contents of /proc/version:
--837--   Linux version 2.6.22.12-0.1-default (geeko@buildhost) (gcc version
4.2.1 (SUSE Linux)) #1 SMP 2007/11/06 23:05:18 UTC
--837-- Arch and hwcaps: AMD64, amd64-sse2
--837-- Page sizes: currently 4096, max supported 4096
--837-- Valgrind library directory: /home/bart/software/valgrind-inner/.in_place
--837-- Reading syms from
/home/bart/software/valgrind-inner/exp-drd/tests/sigalrm (0x400000)
--837-- Reading syms from /lib64/ld-2.6.1.so (0x4000000)
--837--    object doesn't have a symbol table
--837-- Reading syms from
/home/bart/software/valgrind-inner/exp-drd/exp-drd-amd64-linux (0x38000000)
--837--    object doesn't have a dynamic symbol table
--837-- Reading suppressions file:
/home/bart/software/valgrind-inner/.in_place/glibc-2.x-drd.supp
--837-- Reading suppressions file:
/home/bart/software/valgrind-inner/.in_place/default.supp
--837-- Reading syms from
/home/bart/software/valgrind-inner/coregrind/vgpreload_core-amd64-linux.so
(0x4A1D000)
--837-- Reading syms from
/home/bart/software/valgrind-inner/exp-drd/vgpreload_exp-drd-amd64-linux.so
(0x4C1F000)
--837-- Reading syms from /lib64/libpthread-2.6.1.so (0x4E23000)
--837-- Reading syms from /lib64/librt-2.6.1.so (0x503E000)
--837--    object doesn't have a symbol table
--837-- Reading syms from /usr/lib64/libstdc++.so.6.0.9 (0x5247000)
--837--    object doesn't have a symbol table
--837-- Reading syms from /lib64/libm-2.6.1.so (0x554F000)
--837--    object doesn't have a symbol table
--837-- Reading syms from /lib64/libgcc_s.so.1 (0x57A2000)
--837--    object doesn't have a symbol table
--837-- Reading syms from /lib64/libc-2.6.1.so (0x59B0000)
--837--    object doesn't have a symbol table
--837-- REDIR: 0x4e2b2e0 (pthread_mutex_lock) redirected to 0x4c20927
(pthread_mutex_lock)
--837-- REDIR: 0x4e2cc00 (pthread_mutex_unlock) redirected to 0x4c1fe45
(pthread_mutex_unlock)
--837-- REDIR: 0x4e29380 (pthread_create@@GLIBC_2.2.5) redirected to 0x4c20c7f
(pthread_create@*)
--837-- REDIR: 0x4e2a460 (pthread_join) redirected to 0x4c1fac8 (pthread_join)
==837== store 0x64f4760 size 960 thread 1 (vg 2 / drd 1 / off 122637832)
==837==    at 0x504298F: clock_nanosleep (in /lib64/librt-2.6.1.so)
==837==    by 0x400FC6: thread_func(void*) (sigalrm.cpp:59)
==837==    by 0x4C20C6C: vg_thread_wrapper (drd_preloaded.c:156)
==837==    by 0x4E2901F: start_thread (in /lib64/libpthread-2.6.1.so)
==837==    by 0x5A74F8C: clone (in /lib64/libc-2.6.1.so)

drd: drd_main.c:214 (drd_trace_store): Assertion
'DrdThreadIdToVgThreadId(thread_get_running_tid()) == VG_(get_running_tid)()'
failed.
==837==    at 0x3800BB1C: report_and_quit (m_libcassert.c:140)
==837==    by 0x3800BE2A: vgPlain_assert_fail (m_libcassert.c:200)
==837==    by 0x38002D25: drd_trace_store (drd_main.c:213)
==837==    by 0x380593F4: vgPlain_sigframe_create (sigframe-amd64-linux.c:471)
==837==    by 0x38018499: deliver_signal (m_signals.c:1054)
==837==    by 0x38018A0A: async_signalhandler (m_signals.c:1607)
==837==    by 0x380176CF: (within
/home/bart/software/valgrind-inner/exp-drd/exp-drd-amd64-linux)

sched status:
  running_tid=2

Thread 1: status = VgTs_WaitSys
==837==    at 0x4E2A576: pthread_join (in /lib64/libpthread-2.6.1.so)
==837==    by 0x4C1FB41: pthread_join (drd_preloaded.c:249)
==837==    by 0x400F23: main (sigalrm.cpp:94)

Thread 2: status = VgTs_Runnable
==837==    at 0x504298F: clock_nanosleep (in /lib64/librt-2.6.1.so)
==837==    by 0x400FC6: thread_func(void*) (sigalrm.cpp:59)
==837==    by 0x4C20C6C: vg_thread_wrapper (drd_preloaded.c:156)
==837==    by 0x4E2901F: start_thread (in /lib64/libpthread-2.6.1.so)
==837==    by 0x5A74F8C: clone (in /lib64/libc-2.6.1.so)


Note: see also the FAQ.txt in the source distribution.
It contains workarounds to several common problems.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what Linux distro you are using.  Thanks.
Comment 1 Bart Van Assche 2007-12-02 19:40:44 UTC
Solved this in drd.