Bart Van Assche [Thu, 19 Jan 2012 19:52:15 +0000 (19:52 +0000)]
drd: Fix a race condition in the pthread_create() intercept.
Avoid that the futex wake call in DRD_(sema_up)() can get invoked after the semaphore has
already been destroyed. This is most likely the real fix for the bug described in the
commit message of r12332.
Bart Van Assche [Wed, 18 Jan 2012 08:12:16 +0000 (08:12 +0000)]
Pool allocator: change the semantics of VG_(releasePA)() according to comment http://bugs.kde.org/show_bug.cgi?id=282230#c50.
This change also makes the semantics of releasePA match the semantics of
other release functions, e.g. those in XPCOM (see also http://developer.mozilla.org/en/XPCOM_Interface_Reference/nsISupports#Release%28%29).
Add a perf test to measure the speed (and memory) of PDB handling.
* modified perf/heap.c so that it optionally creates a partially defined bytes every N bytes
* created perf/heap_pdb4.vgperf calling heap 4 (so one byte on 4 is PDB in what heap allocates).
before/after pool alloc, here are the performances on a ppc64. So, it looks like
pool alloc also significantly improves the speed of PDB handling.
Fixes 282230 group allocator for small fixed size, use it for MC_Chunk/SEc vbit
* new files include/pub_tool_groupalloc.h and coregrind/m_groupalloc.c
implementing a group allocator (based on helgrind group alloc).
* include/Makefile.am coregrind/Makefile.am : added pub_tool_groupalloc.h
and m_groupalloc.c
* helgrind/libhb_core.c : use pub_tool_groupalloc.h/m_groupalloc.c
instead of the local implementation.
* include/pub_tool_oset.h coregrind/m_oset.c : new function
allowing to create an oset that will use a pool allocator.
new function allowing to clone an oset (so as to share the pool alloc)
* memcheck/tests/unit_oset.c drd/tests/unit_bitmap.c : modified
so that it compiles with the new m_oset.c
* memcheck/mc_main.c : use group alloc for MC_Chunk
memcheck/mc_include.h : declare the MC_Chunk group alloc
* memcheck/mc_main.c : use group alloc for the nodes of the secVBitTable OSet
* include/pub_tool_hashtable.h coregrind/m_hashtable.c : pass the free node
function in the VG_(HT_destruct).
(needed as the hashtable user can allocate a node with its own alloc,
the hash table destroy must be able to free the nodes with the user
own free).
* coregrind/m_gdbserver/m_gdbserver.c : pass free function to VG_(HT_destruct)
* memcheck/mc_replace_strmem.c memcheck/mc_machine.c
memcheck/mc_malloc_wrappers.c memcheck/mc_leakcheck.c
memcheck/mc_errors.c memcheck/mc_translate.c : new include needed
due to group alloc.
Florian Krohm [Sun, 15 Jan 2012 21:02:44 +0000 (21:02 +0000)]
Add support for the s390's TROO insn. These are the valgrind bits.
Detect ETF2 enhancement facility using STFLE. Add testcases.
Patch by Divya Vyas (divyvyas@linux.vnet.ibm.com) with
modifications. Partial fix of #273114
Bart Van Assche [Sun, 15 Jan 2012 19:13:35 +0000 (19:13 +0000)]
drd: Set up red zone before the first instruction of a thread is run.
Avoids that DRD sporadically reports mysterious false positive conflicting accesses on
amd64 like e.g. the following:
$ ./vg-in-place --fair-sched=yes --tool=drd --read-var-info=yes --check-stack-var=yes --show-confl-seg=no drd/tests/annotate_smart_pointer 50 50
==18170== drd, a thread error detector
==18170== Copyright (C) 2006-2011, and GNU GPL'd, by Bart Van Assche.
==18170== Using Valgrind-3.8.0.SVN and LibVEX; rerun with -h for copyright info
==18170== Command: ./annotate_smart_pointer 50 50
==18170==
==18170== Conflicting store by thread 1 at 0x7fefff8a0 size 8
==18170== at 0x400FCE: AnnotateCondVarSignal (unified_annotations.h:32)
==18170== Allocation context: unknown.
==18170==
==18170== Conflicting load by thread 1 at 0x7fefff8a0 size 8
==18170== at 0x400FDD: AnnotateCondVarSignal (unified_annotations.h:34)
==18170== by 0x401071: U_AnnotateHappensBefore (unified_annotations.h:46)
==18170== by 0x4018DD: smart_ptr<counter>::set(counter*, AtomicInt32*) (annotate_smart_pointer.cpp:239)
==18170== by 0x401778: smart_ptr<counter>::operator=(counter*) (annotate_smart_pointer.cpp:208)
==18170== by 0x401377: main (annotate_smart_pointer.cpp:326)
==18170== Allocation context: unknown.
Added a new parameter to the memcheck 'leak_check' GDB monitor command
to let the user specify a max nr of loss records to output : on huge
applications, interactive display of a lot of records in gdb can
take a lot of time.
* mc_include.h :
- added UInt max_loss_records_output; to LeakCheckParams structure
- avoid passing LeakCheckParams by struct copy.
* modified test gdbserver_tests/mcleak to test the new parameter
* mc_main.c : parse or set max_loss_records_output in leak_check cmd
handling and calls.
* mc-manual.xml : document new leak_check parameter
* mc_leakcheck.c :
- extract printing rules logic in its own function
- in print_results, if there is a limit in LeakCheckParam,
compute from where the printing of loss records has to start
* Use the arg name forClient to document the calls to VG_(am_get_advisory)
* in function VG_(am_mmap_file_float_valgrind_flags), use False/*forClient*/
instead of True (as VG_(am_mmap_file_float_valgrind_flags) is used
for "valgrind" kind of mmap only).
Regtested on f16/ppc64, deb5/amd64, Ubuntu9.10/x86
Florian Krohm [Fri, 30 Dec 2011 03:09:45 +0000 (03:09 +0000)]
Fix accounting for MC_(realloc). It was inconsistent as compared to
other wrappers in that it took place before the silly-args check.
Testcase and patch by Yann Droneaud (yann@droneaud.fr).
Fixes #281482
Also included is a related fix to MC_(new_block). Incrementing the
alloc counter and updating the allocated memory amount should
occur under the same condition (allocation succeeded).
fix 289699 vgdb connection in relay mode erroneously closed due to buffer overrun
* use PBUFSIZ+1 for buffers reading characters from gdbserver:
vgdb reads up to PBUFSIZ characters from gdbserver.
If vgdb receives a burst of packet from Valgrind gdbserver, PBUFSIZ
characters can be read. The tracing code adds a trailing \0 to
this buffer => to avoid buffer overrun, the buffers are dimensionned
with PBUFSIZ+1.
* use read_buf in function read_char, rather than directly calling read.
Florian Krohm [Mon, 26 Dec 2011 18:35:29 +0000 (18:35 +0000)]
While investigating whether bugzilla #286040 was a problem or
not (it's not) I noticed that the code was more complex than
it needed to be. So this patch simplifies it a little.
Florian Krohm [Sat, 24 Dec 2011 21:50:53 +0000 (21:50 +0000)]
Beef up VG_(strerror) to provide correct messages for the
errno codes in asm-generic/errno-base.h (on linux).
The error strings were obtained by calling strerror natively in
Linux.
Extend vki-linux.h accordingly. vki-darwin.h already had
those errno codes.
Add testcase. This fixes #287858.
Fix 247386 make perf does not run all performance tests :
* move memcheck/perf/many-loss-records test to perf directory
massif/perf/many-xpts test to perf directory
* modified many-loss-records.vgperf and many-xpts.vgperf,
so as to have tool specific options prefixed with their tool
* remove directory memcheck/perf and massif/perf (containing no test anymore)
* none/tests/linux/mremap3.vgtest : new test
mremap3.c based on testcase provided by Jan Engelhardt
* coregrind/m_syswrap/syswrap-generic.c
- The two 'no-thrash checks' that were introduced to fix bug #129866
were (probably) broken when adress space manager was reworked.
The new VG_(am_get_advisory_client_simple) returns NULL for a free
segment, but the check was based on checking not NULL and then
that the state is free.
=> replaces these two local checks by a call to the new
am Bool VG_(am_covered_by_single_free_segment) function.
* coregrind/pub_core_aspacemgr.h
coregrind/m_aspacemgr/aspacemgr-linux.c
- new function Bool VG_(am_covered_by_single_free_segment)
Bart Van Assche [Sat, 17 Dec 2011 12:53:23 +0000 (12:53 +0000)]
Add a configure test for detecting whether gcc supports atomic operations on
64-bit integers on 32-bit platforms. Apparently newer gcc versions support
this but older versions not. Thanks to Philippe Waroquiers for reporting this.
rev 12001 has introduced a regression in VG_(env_remove_valgrind_env_stuff):
to avoid modifying a possibly read-only env string, the string is duplicated,
and the copy is modified. However, mash_env_column modifies the string
"in-place". The modified string was not put back in the env (and could not,
because the src string is only partially copied).
This means that the valgrind preload strings were not cleaned up and
when a 32 bit executable execs a 64 bits (or vice versa: 64 bit execs 32 bits),
LD_PRELOAD contains both the 32 bits and 64 bits versions of Valgrind
vgpreload.... => ld.so then gives an error msg, as it can't preload either
the 32 or the 64 bits version.
The patch fixes this by duplicating the whole env string, and passing
to mash_colon_env a pointer to the correct offset in the whole env string.
The duplicated string is replacing the original entry in envp.
This patch adds two regression tests : none/tests/allexec32 and
none/tests/allexec64. On a bi-arch valgrind, these will be 32bits and 64 bits
executables, exec-ing each other. On a single arch, one will be a symlink
to the other (to avoid different .exp files, and still test exec).
Give a better help message for gdbserver when VALGRIND_LIB
is set. This ensures a correct help msg is given when
the valgrind installation is moved, and VALGRIND_LIB is
then set to the new valgrind lib location.
Note it does not improve the help msg when valgrind
is run "in place" (e.g. when using vg-in-place).
(Patch from Paul Pluzhnikov).
Florian Krohm [Sat, 26 Nov 2011 04:12:01 +0000 (04:12 +0000)]
Tweaks for the benefit of the webpage.
- mention s390x/linux in README
- formatting tweak in README.s390 so things don't look ugly in html
- add README.s390 and README.android to distribution documents
Florian Krohm [Sat, 26 Nov 2011 04:05:47 +0000 (04:05 +0000)]
Yesterday I changed dist.authors.html and dist.news.html in r442
in the valgrind-www repository. These files are actually generated
from AUTHORS and NEWS, respectively.
Therefore, change AUTHORS and NEWS to reflect yesterday's change.
Things are now in synch again.
Julian Seward [Sun, 20 Nov 2011 09:35:51 +0000 (09:35 +0000)]
arm-linux: fix signal returning so that if SA_RESTORER is not
specified, the handler returns to the previous context rather than to
whatever value happens to be parked in the link register (duh).
Previous behaviour made complete nonsense of signal returning on
Android.
The sparse wa maintains the nr of elements in use at level 0.
So, replace the code which counts the nr of bits in the level0
bitmap by just returning the nr of elements in use.
To detect calls and returns, Callgrind's heuristic
starts with using the jumpkind got from VEX for
a control flow change instruction. However, for
side exits, it always assumed a (conditional) jump,
which holds true for x86, but e.g. not for ARM.
This fixes Callgrind to use the jumpkind found
by VEX for all exits, which should help making
Callgrind work for ARM. It also moves the check
whether a boring jump is actually a fall-through
to instrumentation time. This changes (fixes) the
result for indirect jumps to the next instruction,
which should not be classified as fall-through
(anyway, this case is probably very rare).
This patch introduces an own enum for jump kinds
in Callgrind. This is less confusing than misusing
the VEX jump kind type, as Callgrinds wants
to distinguish BB fall-throughs from real jumps
(which both are Ijk_Boring in VEX).
Also, setup_bbcc now stores separately whether the
jump kind is conditional or not.
This is the last part of moving from command file polling
to the vgdb ptrace method for interactive control of Callgrind.
VG 3.7.x ported callgrind_control to vgdb (in r11867), but
still did command file polling to support existing KCachegrind
releases. KCachegrind from upcoming KDE SC 4.8 will use
callgrind_control instead of manually writing command files.
The main benefit from this is, apart from getting rid of
continous file polling activity in Callgrind, that blocked
processes can now respond to callgrind_control.
Julian Seward [Tue, 8 Nov 2011 19:32:57 +0000 (19:32 +0000)]
When doing instrumentation, pay attention to the Ist.IMark.delta
fields. This makes the --ct-verbose=1 output make a lot more sense
for Thumb code. Should have no effect on any other platform.
Florian Krohm [Fri, 28 Oct 2011 21:37:19 +0000 (21:37 +0000)]
Fix the configure test for ssse3 support. GCC needs -msse or it
will reject the xmm7 clobber in the code snippet.
Fix the prereqs for the ssse3 tests. It is possible that hardware
supports ssse3 but the tool chain does not. So we need to have the
testcase executable as a prerequisite.
Florian Krohm [Fri, 28 Oct 2011 02:45:15 +0000 (02:45 +0000)]
Don't get the date of the build from the mail header. It is
often off-by one. Instead extract it from the message body,
namely, when the build was kicked off.
Florian Krohm [Fri, 28 Oct 2011 00:11:44 +0000 (00:11 +0000)]
Rewrite test to not use function clock_gettime. The purpose
of this is to not have to link against -lrt because that causes
a different back-trace on certain x86 and s390x environments.
See the thread with subject
"helgrind/tests/cond_timedwait_invalid failing on x86"
on valgrind-developers for more details.