|
From: Bart V. A. <bar...@gm...> - 2006-12-29 09:45:41
|
Does anyone know where I can find comprehensive documentation of how ELF
shared library symbols are resolved at runtime ? When running drd on C++
programs drd reports data races on calls to a.o. 'operator new(unsigned)'
(_Znwj) and 'operator delete(void*)' (_ZdlPv). After having traced all
accesses to the memory location on which the data race occurred
(0x08049874), it turned out that the race is caused by the dynamic loader. I
don't think I can suppress this race using Valgrind's suppression mechanism
because the race is reported before the _dl* function names appear in the
call stack. If I understand more about dynamic loading, maybe I can find out
the address of the conflicting location before the _dl* functions are
called.
Bart.
$ cat new_delete.cpp
#include <pthread.h>
void* thread_func(void*)
{
delete new int;
return 0;
}
int main(int argc, char** argv)
{
pthread_t tid;
pthread_create(&tid, 0, thread_func, 0);
delete new int;
pthread_join(tid, 0);
return 0;
}
$ VALGRIND_LIB=.in_place coregrind/valgrind --suppressions=drd/default.supp
--tool=drd --trace-address=134518912 drd/tests/new_delete
==22662== drd, a data race detector.
==22662== Copyright (C) 2006, and GNU GPL'd, by Bart Van Assche.
THIS SOFTWARE IS A PROTOTYPE, AND IS NOT YET RELEASED
==22662== Using LibVEX rev 1680, a library for dynamic binary translation.
==22662== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==22662== Using valgrind-3.3.0.SVN, a dynamic binary instrumentation
framework.
==22662== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==22662== For more details, rerun with: -v
==22662==
==22662== load 0x8049880 size 4 thread 1
==22662== at 0x400A613: _dl_relocate_object (in /lib/ld-2.4.so)
==22662== by 0x4004777: dl_main (in /lib/ld-2.4.so)
==22662== by 0x40131CA: _dl_sysdep_start (in /lib/ld-2.4.so)
==22662== by 0x40011F3: _dl_start (in /lib/ld-2.4.so)
==22662== by 0x4000846: (within /lib/ld-2.4.so)
==22662== store 0x8049880 size 4 thread 1
==22662== at 0x400A613: _dl_relocate_object (in /lib/ld-2.4.so)
==22662== by 0x4004777: dl_main (in /lib/ld-2.4.so)
==22662== by 0x40131CA: _dl_sysdep_start (in /lib/ld-2.4.so)
==22662== by 0x40011F3: _dl_start (in /lib/ld-2.4.so)
==22662== by 0x4000846: (within /lib/ld-2.4.so)
==22662== load 0x8049880 size 4 thread 2
==22662== at 0x80484B8: (within
/home/bart/software/valgrind-svn/drd/tests/new_delete)
==22662== by 0x4022E2C: vg_thread_wrapper (drd_preloaded.c:133)
==22662== by 0x404434A: start_thread (in /lib/libpthread-2.4.so)
==22662== by 0x421C65D: clone (in /lib/libc-2.4.so)
==22662== store 0x8049880 size 4 thread 2
==22662== at 0x400D274: _dl_fixup (in /lib/ld-2.4.so)
==22662== by 0x401262F: _dl_runtime_resolve (in /lib/ld-2.4.so)
==22662== by 0x4022E2C: vg_thread_wrapper (drd_preloaded.c:133)
==22662== by 0x404434A: start_thread (in /lib/libpthread-2.4.so)
==22662== by 0x421C65D: clone (in /lib/libc-2.4.so)
==22662== Conflicting load by thread 1 at 0x08049874 size 4
==22662== at 0x8048488: (within
/home/bart/software/valgrind-svn/drd/tests/new_delete)
==22662== by 0x417487B: (below main) (in /lib/libc-2.4.so)
==22662== Allocation context: drd/tests/new_delete, NONE:Data
==22662== Other segment start (thread 2)
==22662== (thread finished, call stack no longer available)
==22662== Other segment end (thread 2)
==22662== (thread finished, call stack no longer available)
==22662== load 0x8049880 size 4 thread 1
==22662== at 0x80484B8: (within
/home/bart/software/valgrind-svn/drd/tests/new_delete)
==22662== by 0x417487B: (below main) (in /lib/libc-2.4.so)
==22662==
==22662== Conflicting load by thread 1 at 0x08049880 size 4
==22662== at 0x80484B8: (within
/home/bart/software/valgrind-svn/drd/tests/new_delete)
==22662== by 0x417487B: (below main) (in /lib/libc-2.4.so)
==22662== Allocation context: drd/tests/new_delete, NONE:Data
==22662== Other segment start (thread 2)
==22662== (thread finished, call stack no longer available)
==22662== Other segment end (thread 2)
==22662== (thread finished, call stack no longer available)
==22662==
==22662== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 6 from 3)
|