Florian Krohm [Mon, 16 Mar 2015 22:03:42 +0000 (22:03 +0000)]
Increase the size of the alternate stack. It was too small.
This was found by accident and there is no known way to detect
an overflow of an alternate stack in the general case.
New Option --avg-transtab-entry-size=<number> can be used to tune
the size of the translation table sectors, either to gain memory
or to avoid too many retranslations.
Fix the following errors detected by makefile check
memcheck/tests/Makefile.am:1: error: wrap8.stderr.exp-ppc64 is missing in EXTRA_DIST
memcheck/tests/Makefile.am:1: error: wrap8.stdout.exp-ppc64 is missing in EXTRA_DIST
memcheck/tests/Makefile.am:1: error: wrap8.stdout.exp2 is in EXTRA_DIST but doesn't exist
memcheck/tests/Makefile.am:1: error: wrap8.stderr.exp2 is in EXTRA_DIST but doesn't exist
Florian Krohm [Sat, 14 Mar 2015 10:15:23 +0000 (10:15 +0000)]
Organise the expected output files for the wrap8 testcase.
There is special behaviout on ppc64 only. Let the filenames
reflect that. At the same time update the ppc specific
output to what it is. The important thing here is that the
stack overflow is detected. Everything else is effectively a
don't care. Should line numbers and such differ in the future
that should be filtered out.
Florian Krohm [Sat, 14 Mar 2015 09:44:04 +0000 (09:44 +0000)]
Update the ppc64 specific results to what they are.
The difference of the expected results as compared to other
platforms is
- Location 0x........ is 2 bytes inside local var "budget"
- declared at varinfo6.c:3115, in frame #2 of thread 1
+ Address 0x........ is on thread 1's stack
+ in frame #2, created by BZ2_blockSort (varinfo6.c:3107)
Should the stderr output of this testcase in the future
match the generic output (varinfo6.stderr.exp) then this is
another incarnation of
https://bugs.kde.org/show_bug.cgi?id=345121
Florian Krohm [Fri, 13 Mar 2015 13:50:08 +0000 (13:50 +0000)]
Sort locks by their guestaddr to make the error output independent
of the dynamically allocated Lock addresses.
This restores helgrind/tests/locked_vs_unlocked2.stderr.exp
from r14931.
While regtesting the patch I've observed intermittent failures
of helgrind/tests/hg05_race2 like so:
--- ../../helgrind/tests/hg05_race2.stderr.exp (revision 15001)
+++ ../../helgrind/tests/hg05_race2.stderr.exp (working copy)
@@ -26,8 +26,7 @@
at 0x........: th (hg05_race2.c:17)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
...
- Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
- declared at hg05_race2.c:24, in frame #x of thread x
+ Address 0x........ is on thread #x's stack
@@ -42,8 +41,7 @@
at 0x........: th (hg05_race2.c:17)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
...
- Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
- declared at hg05_race2.c:24, in frame #x of thread x
+ Address 0x........ is on thread #x's stack
m_transtab.c statistic/tracing
* common up the identical debug and clo_stat traces
* add in the stats the nr of sectors recycled
* add the avg translation size in each sector recycled
and in the final statistics
(no functional change)
Implement command line option --valgrind-stacksize=<number>
This allows to decrease memory usage when using many threads,
if no big stacksize is needed by Valgrind.
If needed (e.g. for demangling big c++ symbols), the V stacksize
can be increased.
Florian Krohm [Thu, 12 Mar 2015 18:56:21 +0000 (18:56 +0000)]
Fix two bugs:
(1) In r14664 VG_(get_fnname_if_entry) was changed to always
return a function name, even if that function was *not* an
entry. That broke callgrind and was also confusing because
it contradicts what "get_fnname_if_entry" suggests.
(2) In r14189 a function call was removed because it was considered
redundant which it was not.
Both bugs were hunted down by Joseph Weidendorfer.
Florian Krohm [Tue, 10 Mar 2015 20:46:58 +0000 (20:46 +0000)]
Issue a warning if a function has more than 5 million bytes of
code. Previously functions exceeding that size were observed in the
field. Assert for 100x that amount.
Florian Krohm [Tue, 10 Mar 2015 16:13:59 +0000 (16:13 +0000)]
Add support for building with -fsanitize=undefined.
- add configure option --enable-ubsan
- add __ubsan helpers (by Julian)
This requires gcc 4.9.2 or later. Not all platforms are supported, though.
With this change and VEX r3099 regression tests pass on amd64
with a valgrind compiled with -fsanitize=undefined.
Florian Krohm [Sat, 7 Mar 2015 23:01:14 +0000 (23:01 +0000)]
New function VG_(am_mmap_client_heap) which swallows
VG_(am_set_segment_isCH_if_SkAnonC).
Rename VG_(am_set_segment_hasT_if_client_segment) to
VG_(am_set_segment_hasT) passing in an address (because that function
cannot possible take a pointer to a *const* segment). Also assert that
the segment containing the address is a client segment. Everything else
is a bug.
update NEWS to indicate that
335907 segfault when running wine's ddrawex/tests/surface.c under valgrind
is assumed to be fixed either by a previous change in 3.10
and/or by the commit for 343173
Rhys Kidd [Sat, 7 Mar 2015 14:57:39 +0000 (14:57 +0000)]
n-i-bz: Replace non-POSIX bzero with proper memset. At least for internal-only, Darwin functionality. Picked up by cppcheck. No regressions within test suite.
Rhys Kidd [Sat, 7 Mar 2015 08:36:20 +0000 (08:36 +0000)]
Fix unhandled syscall: unix:348 (__pthread_chdir) and unhandled syscall: unix:349 (__pthread_fchdir) on OS X
bz#344512
- Support these two undocumented syscalls.
- New regression test case added.
Rhys Kidd [Sat, 7 Mar 2015 05:22:12 +0000 (05:22 +0000)]
Fix stack traces missing penultimate frame
bz#344560
- Also fixes memcheck/tests/badpoll test on OS X
- Problem occurs because the guest stack seen in a system call pre or post
function happens to not have a correct topmost stack frame, as Darwin system
call stubs do not start with the usual function prolog.
- New regression test case added.
- Thanks to Greg Banks for research, patch and test case.
Julian Seward [Thu, 5 Mar 2015 00:52:07 +0000 (00:52 +0000)]
Minor changes in an attempt to improve performance and reduce
the amount of file-reading resulting from DiImage-cache misses.
CACHE_N_ENTRIES:
Increase the DiImage cache size from 256KB to 8MB to deal with
drastically worse locality when reading inline info. The 256KB
setting dates from befre inline-info-reading days.
is_in_CEnt: remove a conditional branch from the hot path (of |get|,
effectively)
This fixes a helgrind crash detected on android.
Android bionic pthread lib unmaps the stack for detached threads
before exiting.
Helgrind tries to unwind the stack to record a 'read' after
the stack unmap, just before the exit syscall.
The unwind then causes a SEGV.
The solution consists in tightening the calculation of
the stack limits, so as to stop unwinding when no valid stack
can be found.
Regression test reproduces the same problem by simulating the
bionic behaviour on linux, using asm similar to bionic lib.
Florian Krohm [Tue, 3 Mar 2015 14:56:17 +0000 (14:56 +0000)]
Produce a user message in case of stack overflow.
Change VG_(extend_stack) and VG_(am_extend_into_adjacent_reservation_client)
accordingly.
Remove some redundant checking.
Add testcase.
Rhys Kidd [Sun, 1 Mar 2015 13:22:21 +0000 (13:22 +0000)]
Fix missing libobjc suppressions on OS X 10.10
bz#344702
- Update darwin14.supp suppressions
- Includes malloc_zone_malloc and malloc related issues in system libraries
Rhys Kidd [Fri, 27 Feb 2015 11:34:07 +0000 (11:34 +0000)]
Fix memcheck/tests/err_disable4 test on OS X
bz#344621
- Unnamed semaphores are not supported on OS X, must use named semaphores.
- To use named semaphores sem_open() instead of sem_init() utilised.
- Test case updated accordingly across all platforms.
Florian Krohm [Thu, 26 Feb 2015 21:48:19 +0000 (21:48 +0000)]
Simplify do_brk
- remove redundant asserts
- let VG_(am_extend_into_adjacent_reservation_client) worry about
- whether delta is too large
- whether the segment abutting this one exists and is a reservation
segment
The function already checks these things. No need to do it again here.
- do_brk does not need to know that a reservation segment must not
shrink beyond a single page. That detail ought to be hidden in
the address space manager.
Also, turn a few conditions into asserts.
Mark Wielaard [Wed, 25 Feb 2015 14:00:14 +0000 (14:00 +0000)]
Bug #344318 socketcall should wrap recvmmsg and sendmmsg
Some architectures, e.g. s390, don't have dedicated recvmmsg and sendmmsg
system calls, but use the socketcall multiplexing system call with
SYS_RECVMMSG or SYS_SENDMMSG (just like the accept4 systemcall can also
be called through socketcall). Create separate helpers for recvmmsg and
sendmmsg helpers that can be used by either the direct syscall or the
socket call.
Florian Krohm [Wed, 25 Feb 2015 10:06:06 +0000 (10:06 +0000)]
Change VG_(am_extend_map_client) as follows:
- Tighten up on asserts
- Simplify; as the function grows memory into a free segment, there
cannot possibly be any translations to be discarded. Free segments
do not have translations. sane_NSegment will make sure.
- Change the prototype to take in the start address of the mapping and
return a pointer to the resized segment. Previously, the code
ok = VG_(am_extend_map_client)( &d, old_seg, needL );
if (!ok)
goto eNOMEM;
VG_TRACK( new_mem_mmap, needA, needL,
old_seg->hasR, old_seg->hasW, old_seg->hasX,
was examining old_seg->hasR etc even though VG_(am_extend_map_client)
stated that *old_seg was invalid after the function returned.
That wasn't exactly a problem, but clearly looked wrong.
Julian Seward [Tue, 24 Feb 2015 12:24:35 +0000 (12:24 +0000)]
Handle new IROps added in vex r3092:
Iop_RecipStep64Fx2, Iop_RSqrtStep64Fx2
Iop_RSqrtEst64Fx2, Iop_RecipEst64Fx2
Iop_RecpExpF64, Iop_RecpExpF32
--This line, and those below, will be ignored--
Fix configure for Linux kernel >= 4.0-rc1
In addition raise the minimal Linux version to 2.6 as there is almost
no test coverage for 2.4 and 2.6 was released in 2003.
Florian Krohm [Fri, 20 Feb 2015 14:00:23 +0000 (14:00 +0000)]
Pass in a mask of segment kinds to VG_(get_segment_starts)
and VG_(am_get_segment_starts) to indicate which segments
should be collected. That should solve the following problem:
in m_main.c we used to:
for (i = 0; i < n_seg_starts; i++) {
Word j, n;
NSegment const* seg
= VG_(am_find_nsegment)( seg_starts[i] );
vg_assert(seg);
if (seg->kind == SkFileC || seg->kind == SkAnonC) {
...
// ... dynamic memory allocation for valgrind
...
}
This caused the vassert(seg) to fire because the dynamic memory
allocation further down the loop changed segments such that a
valgrind segment which used to be non-SkFree suddenly became
SkFree and hence VG_(am_find_nsegment) returned NULL. Whoom.
With this revision we only collect the segments we're really
interested in. For the example above that is all client segments.
So if V allocates memory -- fine. That will not change the layout
of client segments.
Julian Seward [Fri, 20 Feb 2015 12:29:59 +0000 (12:29 +0000)]
canonicaliseSymtab: fix silly logic that could cause the function to
loop forever. In particular, it will do that when two symbols have
exactly the same address range but differ in their .isText attribute.
Fixes #342117.
Escape newlines in command arguments for "cmd:" header field in dumps
We could do unescaping in callgrind_annotate, but a escaped command
even seems better there.
Julian Seward [Wed, 18 Feb 2015 12:57:06 +0000 (12:57 +0000)]
Improve string table reading for MSVC2010 compiled code. Also seems
to help with MSVC2013 compiled code. Variant of a patch from
Mark Browning (mabrowningrr@gmail.com). Fixes #211529.
Julian Seward [Tue, 17 Feb 2015 13:46:26 +0000 (13:46 +0000)]
ML_(find_name_of_pdb_file): bit a bit more careful when grepping the
output from /usr/bin/strings, so as to not get confused by substrings
".pdb" and ".PDB" when they don't appear at the end of a line.
Florian Krohm [Mon, 16 Feb 2015 23:04:53 +0000 (23:04 +0000)]
Update comment for VG_(am_find_nsegment) to match the code.
Likewise for VG_(am_next_nsegment). Also make the code similar to
VG_(am_find_nsegment) for easier comprehension.
Florian Krohm [Mon, 16 Feb 2015 22:58:30 +0000 (22:58 +0000)]
Translations are allowed from all client segments. Update comments
and rename VG_(am_set_segment_hasT_if_SkFileC_or_SkAnonC) to
VG_(am_set_segment_hasT_if_client_segment). Change it so it handles
all client segments.
Florian Krohm [Sat, 14 Feb 2015 21:17:46 +0000 (21:17 +0000)]
Misc tweaks in segAddr_to_index:
(1) It is always invalid for the incoming segment pointer to be
out of range. Assert that.
(2) Let the compiler do the address arithmetic. They're good at that
and therefore:
(3) No asserts needed to check the result.
Florian Krohm [Fri, 13 Feb 2015 19:08:26 +0000 (19:08 +0000)]
Add command line flag --max-threads=<integer> to increase the number of
threads that valgrind can handle. No recompile is needed.
Part of fixing BZ #337869.
Julian Seward [Wed, 11 Feb 2015 19:46:27 +0000 (19:46 +0000)]
arm32-linux: for the magic-call CALL_FN_* macros, add r12 to the asm
trash list. Not doing so was causing r12 to get corrupted by the
called function, which lead to some very strange failures in Helgrind
on arm32. Fixes #344033.
Julian Seward [Wed, 11 Feb 2015 00:49:45 +0000 (00:49 +0000)]
arm32-linux: GET_STARTREGS has always been wrong on this target,
confusing SP and LR and resulting in no backtraces during internal
assertion failures etc on this platform. Fixes #343219. Noticed by
dimitry@google.com.
Julian Seward [Wed, 11 Feb 2015 00:41:48 +0000 (00:41 +0000)]
arm32: local_sys_write_stderr and local_sys_getpid: don't trash r7
in the inline assembly, because gcc doesn't like that when compiling
for Thumb. And this file is compiled for Thumb during "make check".
Mark Wielaard [Tue, 10 Feb 2015 13:39:04 +0000 (13:39 +0000)]
Bug #344007 accept4 syscall unhandled on arm64 (242) and ppc64 (344)
ppc64 might fall back to socketcall in some cases, but arm64 always uses
accept4 syscall directly. Some (confusing) background on when/how glibc
(wrongly) decides to use a direct accept4 or the socketcall system call:
https://sourceware.org/ml/libc-alpha/2013-12/msg00014.html
Ensure vgdb gets the nr of threads from Valgrind via shared memory,
rather than using a compile time constant.
This is in preparation for a future change by Florian, to have
the max nr of threads specifiable at startup via a clo