5424 Commits

Author SHA1 Message Date
Philippe Waroquiers
619fb35df7 Fix 376257 - helgrind history full speed up using a cached stack
This patch implements the flag --delta-stacktrace=yes/no.
Yes indicates to calculate the full history stack traces by
changing just the last frame if no call/return instruction was
executed.
This can speed up helgrind by up to 25%.

This flags is currently set to yes only on linux x86 and amd64, as some
platform dependent validation of the used heuristics is needed before
setting the default to yes on a platform. See function check_cached_rcec_ok
in libhb_core.c for more details about how to validate/check the behaviour
on a new platform.
2017-11-02 21:33:35 +01:00
Petar Jovanovic
0eea388934 android: compute possible size of a symbol of unknown size
Under specific circumstances, setting 2048 as a size of symbol of unknown
size causes that symbol crosses unmapped region. This further causes an
assertion in Valgrind.

Compute possible size by computing maximal size the symbol can have within
its section.

Patch by Tamara Vlahovic.
2017-10-31 18:00:38 +01:00
Petar Jovanovic
13577bb699 mips: detect presence of MSA
Detect presence of MSA capabilities.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Minor code-style rewrites by myself.

Related BZ issue - #382563.
2017-10-27 16:27:24 +02:00
Rhys Kidd
1ce04c35c2 Preliminary support for Darwin 17.x (macOS 10.13) 2017-10-01 19:45:10 -04:00
Rhys Kidd
ed6ad13bc8 Fix missing workq_ops operations (macOS)
Related to discussion in bz#383723. Patch based upon one provided by
Andy Maloney.
2017-10-01 19:05:48 -04:00
Philippe Waroquiers
8259193f1c On ppc, add generic_start_main.isra.0 as a below main function
We can have stacktraces such as:
==41840==    by 0x10000927: a1 (deep.c:27)
==41840==    by 0x1000096F: main (deep.c:35)
==41840==    by 0x4126BEB: generic_start_main.isra.0 (in /usr/lib64/libc-2.17.so)
==41840==    by 0x4126E13: __libc_start_main (in /usr/lib64/libc-2.17.so)

So, add generic_start_main.isra.0 as a below main function.
This fixes the test  massif/tests/deep-D
2017-09-23 13:49:05 +02:00
Philippe Waroquiers
f1ff8597ef Implement static TLS code for more platforms
gdbserver_tests/hgtls is failing on a number of platforms
as it looks like static tls handling is now needed.
So, omplement static tls for a few more platforms.
The formulas that are platform dependent are somewhat wild guesses
obtained with trial and errors.
Note that arm/arm64/ppc32 are not (yet) done
2017-09-19 23:17:48 +02:00
Philippe Waroquiers
621cde90f7 Fix Bug 255603 - exp-sgcheck Assertion '!already_present' failed
The code handling array bounds is not ready to accept a reference
to something else (not very clear what this reference could be) :
the code only expects directly the value of a bound.
So, it was using the reference (i.e. an offset somewehere in the debug
info) as the value of the bound.
This then gave huge bounds for some arrays, causing an overlap
in the stack variable handling code in exp-sgcheck.

Such references seems to be used sometimes for arrays with variable
size stack allocated.

Fix (or rather bypass) the problem by not considering that we have
a usable array bound when a reference is given.
2017-09-13 22:47:11 +02:00
Rhys Kidd
128fd6e6a5 Fix syscall param msg->desc.port.name on macOS 10.12. bz#379373
Based upon patch from Louis Brunner.
2017-09-10 10:50:06 -04:00
Rhys Kidd
55fe390c7a Fix missing pselect syscall (OS X 10.11). bz#379748
Based upon patch from Louis Brunner.
2017-09-03 12:55:52 -04:00
Ivo Raisr
efa1e5ef8d VEX register allocator version 3.
Implements a new version of VEX register allocator which
keeps the main state per virtual registers, as opposed
to real registers in v2. This results in a simpler and
cleaner design and much simpler implementation.
It has been observed that the new allocator executes 20-30%
faster than the previous one but could produce slightly worse
spilling decisions. Overall performance improvement when running
the Valgrind performance regression test suite has been observed
in terms of a few percent.

The new register allocator (v3) is now the default one.
The old register allocator (v2) is still kept around and can be
activated with command line option '--vex-regalloc-version=2'.

Fixes BZ#381553.
2017-08-28 12:40:17 +02:00
Ivo Raisr
ad1c929a82 Recognize signal 151 (SIGLIBRT) sent by gdb.
It has been observed that gdb on Solaris sends this signal to
child processes. Unfortunately array "pass_signals" was too small
to accomodate this signal and subsequently VG_(clo_vex_control).iropt_verbosity
was overwritten.
This has been fixed now.
2017-08-21 16:24:00 +02:00
Austin English
9c23c8cc78 fix verbose version reporting for git
Signed-off-by: Austin English <austinenglish@gmail.com>
2017-08-14 15:27:36 +02:00
Philippe Waroquiers
90dbfce36b Ensure host stack trace has better chance to work when valgrind is exiting
When investigating bug 383275, the host stacktrace was containing
only one IP. This is because the tid corresponding to the lwpid
is dead, and so no valid thread state was returned.
This then gave a rubbish stacktop of 0, which means unwinding
stops at first frame.

So, try harder to find a valid thread state when reporting the
host stacktrace.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16470
2017-08-08 21:15:45 +00:00
Philippe Waroquiers
7d84a435a8 Fix 383275 - massif valgrind: m_xarray.c:162 (ensureSpaceXA): Assertion '!xa->arr' failed
When a massif xtree snapshot is taken when no allocation was done,
the xtree contains no exe context.
The data structure ips_order_xecu is then szied to 0 using VG_(hintSizeXA).
m_xarray.c then allocates an empty array, while later on, a zero size
is expected to correspond to no allocated array.

Fix the problem in m_xarray.c, by not doing any allocation if the
size hint is 0.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16469
2017-08-08 19:52:03 +00:00
Ivo Raisr
34dd8493de Fix handling command line option --xml-socket.
Fixes BZ#382998
Patch by: Orgad Shaneh <orgads@gmail.com>



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16467
2017-08-03 05:22:01 +00:00
Philippe Waroquiers
eec7606c5b Fix 382515 - valgrind: "Assertion 'di->have_dinfo' failed." on wine's dlls/mscoree/tests/mscoree.c
* produce (more) user messages when valgrind cannot read a pdb file.
* recover properly from an invalid/unsupported pdb file.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16465
2017-07-31 20:43:43 +00:00
Ivo Raisr
dfbf6cca38 Fix the Solaris build after development trunk has been renamed.
Effectively Solaris 12 is now becoming Solaris 11.4.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16464
2017-07-31 15:24:08 +00:00
Philippe Waroquiers
035340940f valgrind core side for Add inner requests in VEX (cfr revision 3399)
When running Valgrind under Valgrind, the VEX memory allocation
(temporary or permanent) was not checked, as there was no
inner request.
This patch changes VEX to mark the temporary and permanent
allocations with redzone, and memory is marked unaddressable
when the VEX temporary pool is cleared.

The changes are:
* add a file libvex_inner.h which mostly takes over what
  was in pub_core_inner.h (which now just includes libvex_inner.h)

* modify main_util.h and main_util.c to mark the temporary
  and permanent pool with memcheck pool requests to indicate
  when a block is allocated or freed.

* Impact is (should be) none, unless Valgrind is configured
  as an inner.

* Outer memcheck/inner regression tests run on gcc20 (amd64).
  Nothing (more worrying than the 3.13 self hosting) detected



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16462
2017-07-27 19:11:21 +00:00
Philippe Waroquiers
af72da8cec fix misleading indentation
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16460
2017-07-21 18:46:35 +00:00
Mark Wielaard
0dc5853b9e Bug 381805 arm32 needs ld.so index hardwire for new glibc security fixes
glibc added some security hardening adding (optimized) index/strchr
calls in the LD_PRELOAD path:

    commit 6d0ba622891bed9d8394eef1935add53003b12e8
    Author: Florian Weimer <fweimer@redhat.com>
    Date:   Mon Jun 19 22:31:04 2017 +0200

        ld.so: Reject overly long LD_PRELOAD path elements

arm32 doesn't have an ld.so hardwire for index/strchr like other
architectures and so will always complain during early startup:

    ==9495== Conditional jump or move depends on uninitialised value(s)
    ==9495==    at 0x401CF84: index (in /usr/lib/ld-2.25.so)
    ==9495==
    ==9495== Conditional jump or move depends on uninitialised value(s)
    ==9495==    at 0x401CF88: index (in /usr/lib/ld-2.25.so)

index/strchr is doing a word load from a partially-written
stack-allocated buffer, therefore accessing uninitialized data.
This is normal for an optimized string function. The uninitialized
data does not affect the function result.

This can be suppressed by adding a index hardwire for ld.so on arm32
like on other arches. There even was already some commented out code
to do that. Enable that code.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16458
2017-07-05 09:57:48 +00:00
Tom Hughes
02b719e7b2 Revert r16455.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16456
2017-06-26 12:14:29 +00:00
Tom Hughes
1038ee89e5 Allow setuid/setgid/setcap binaries to be run if
valgrind is running as root.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16455
2017-06-26 12:10:42 +00:00
Philippe Waroquiers
2436a4ad6f After fork, vgdb activity is polled according to the nr of bbs done :
once the nr of bbs done reaches the next vgdb poll, a check for vgdb
activity is done.
This might lead to the activation of gdbserver after fork.
Such poll is however not expected, unless the children is
to be trace.
This spurious poll in the forked child can cause failures
depending on the nr of bbs done before the fork, and the
nr of bbs done between the fork and the exec.

=> disable vgdb poll in the child in the cleanup after fork
in the child, unless the children have to be traced.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16454
2017-06-25 20:25:50 +00:00
Mark Wielaard
3ac87cf927 epoll_pwait can have a NULL sigmask.
According to the epoll_pwait(2) man page:

       The  sigmask  argument  may  be  specified  as  NULL,  in  which  case
       epoll_pwait() is equivalent to epoll_wait().

But doing that under valgrind gives:

==13887== Syscall param epoll_pwait(sigmask) points to unaddressable byte(s)
==13887==    at 0x4F2B940: epoll_pwait (epoll_pwait.c:43)
==13887==    by 0x400ADE: main (syscalls-2007.c:89)
==13887==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

This is because the sys_epoll_pwait wrapper has:

   if (ARG4)
      PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) );

Which looks like a typo (ARG4 is timeout and ARG5 is sigmask).

This shows up with newer glibc which translates an epoll_wait call into
an epoll_pwait call with NULL sigmask.

Fix typo and add a testcase.

https://bugs.kde.org/show_bug.cgi?id=381289

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16451
2017-06-17 13:49:22 +00:00
Julian Seward
1496c7075a fix: Bug 380202 - Assertion failure for cache line size (vg_assert(cls == 64)) on aarch64.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16438
2017-06-09 13:13:48 +00:00
Philippe Waroquiers
01a403d118 Fix 380200 - xtree generated callgrind files refer to files without directory name
Patch from  Matthias Schwarzott, slightly modified



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16435
2017-06-02 21:15:04 +00:00
Julian Seward
fd35201b86 Back out r16414 (Enable fair scheduling by default on Linux.) following
further investigations showing large performance losses in some case, and no
obvious way to fix the problem.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16428
2017-06-01 05:46:54 +00:00
Ivo Raisr
75e99530c2 Ignore sim hint "no-nptl-pthread-stackcache"
on Solaris and Mac OS X. Do not produce a warning
message when it is given.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16424
2017-05-31 13:47:57 +00:00
Julian Seward
d8837cc0fa Enable fair scheduling by default on Linux. n-i-bz.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16414
2017-05-24 14:07:49 +00:00
Julian Seward
4a06d64ce5 When a thread hints that it is in a spin-wait loop (eg, x86 REP NOP insn),
deschedule the thread much sooner (300 evchecks) than previously (1000
evchecks).  Once the thread is spinning, there's absolutely no point in
continuing with it, since only a different thread can get it out of the loop,
so we need to drop the current thread ASAP.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16412
2017-05-24 13:42:33 +00:00
Ivo Raisr
2cc0e531ec Port changes from r16407 to Solaris OS.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16411
2017-05-23 21:37:50 +00:00
Julian Seward
021981c5a5 Enable reading of inlined unwind info for exp-dhat. n-i-bz.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16408
2017-05-22 08:53:37 +00:00
Julian Seward
7f2c63135b Make the message "brk segment overflow in thread #%u: can't grow to %#lx"
be printed only once, rather than every time it happens.  Also make it
not be printed in silent mode (-q).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16407
2017-05-22 08:50:07 +00:00
Julian Seward
8524c53d30 Increase the size of the translation cache to keep up with the demands
of running modern large applications:

* the maximum number of sectors is increased from 24 to 48

* the default number of sectors is increased from 16 to 32 on all targets
  except Android

* the default number of sectors is increased from 6 to 12 on Android targets



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16406
2017-05-22 08:47:24 +00:00
Julian Seward
559b207372 Fix order of strings in a warning message, that has always been wrong.
n-i-bz.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16405
2017-05-22 08:41:07 +00:00
Julian Seward
20b6c5f506 Bug 379966 - WARNING: unhandled amd64-linux syscall: 313 (finit_module).
Patch from Bartosz Golaszewski (bartekgola@gmail.com).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16403
2017-05-22 07:53:04 +00:00
Ivo Raisr
70e9a82f07 POST syscall wrapper for clock_gettime was not properly hooked up on Solaris.
This resulted in false positive undefined warnings.
Fixes BZ#379895.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16392
2017-05-17 04:36:06 +00:00
Petar Jovanovic
d67efc1754 mips64: add a workaround for Cavium CPUs to support mips32r1-r2-mips64r1
Linux kernel incorrectly shows that MIPS Cavium CPUs do not support mips32r1,
mips32r2 and mips64r1. This is due to incorrect defines in

arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h

that affect show_cpuinfo() function.

Until that is changed in Linux kernel, we need a workaround in Valgrind, so
all supported ISAs can be executed correctly.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16390
2017-05-16 16:31:16 +00:00
Julian Seward
23f18278b6 Redo rev 16384 to use the "house" conditionalisation scheme. Pertains to
BZ#368529.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16386
2017-05-16 09:30:50 +00:00
Ivo Raisr
b3cc4dcf7e Implement required stubs for Android on arm when built with clang/llvm.
Fixes BZ#368529
Slightly modified patch by: Elliott Hughes <enh@google.com>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16384
2017-05-16 08:50:48 +00:00
Ivo Raisr
eb42c054c4 Increase Valgrind's load address to prevent mmap failure.
Fixes BZ#374963.

Previously Valgrind failed to start when the executable contained
large text, data or bss segments. The load address was increased
for almost all platforms to 0x58000000 (from 0x38000000),
giving another 512 MB for the executable.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16383
2017-05-16 08:22:51 +00:00
Julian Seward
e706fbfa9f Bug 368507 - valgrind throws std::bad_alloc on memory allocations larger than 34255421416 bytes.
Increase the amount of usable memory from 64GB to 128GB on Linux and Solaris.
(Solaris bits from Ivo Raisr.)  OSX is so far unchanged.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16381
2017-05-16 06:20:26 +00:00
Julian Seward
306353a8d2 arm64-linux: detect Cavium CPUs (implementer = 0x43) and enable the
fallback LLSC implementation in that case.  Pertains to bug #369459.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16380
2017-05-16 05:35:23 +00:00
Philippe Waroquiers
54e6c1e1fd Fix 2 errors found by PVS studio
(see  https://www.viva64.com/en/b/0504/ and bug 379502)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16379
2017-05-15 21:00:16 +00:00
Petar Jovanovic
81ba51146e mips: implement set/long_jmp instead of builtins
- VG_MINIMAL_SETJMP and VG_MINIMAL_LONGJMP for VGP_mips64_linux are defined.
- Implementation of VG_MINIMAL_SETJMP and VG_MINIMAL_LONGJMP for mips32 is
  improved by rescuing FP registers.

This should unbreak mips64/clang build.

Patch by Aleksandar Rikalo.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16378
2017-05-15 14:56:22 +00:00
Ivo Raisr
87d60b9d01 Fix a build problem introduced by SVN commit r16365.
Fixes BZ#370028
Patch by: Tamara Vlahovic <tamara.vlahovic@imgtec.com>



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16377
2017-05-15 11:01:28 +00:00
Ivo Raisr
3ac5c1b50a Reduce the number of compiler warnings on MIPS platforms in coregrind/m_mallocfree.c
Fixes BZ#370028
Patch by: Tamara Vlahovic <tamara.vlahovic@imgtec.com>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16368
2017-05-12 17:18:05 +00:00
Ivo Raisr
3b12d0e199 Fix build problems on Solaris and OS X.
Follow up to SVN r16364.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16366
2017-05-12 01:37:33 +00:00
Ivo Raisr
5e36988bea Reduce the number of compiler warnings on MIPS platforms in coregrind/launcher-linux.c
Fixes BZ#370028
Patch by: Tamara Vlahovic <tamara.vlahovic@imgtec.com>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16365
2017-05-12 01:16:01 +00:00