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.
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.
Ivo Raisr [Fri, 28 Jul 2017 20:49:20 +0000 (20:49 +0000)]
Check whether it is ok to use compiler flag '-pie'.
Some compilers actually do not support -pie and report its usage
as an error. We need to check if it is safe to use it first.
n-i-bz
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
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.
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.
At the beginning of a Valgrind gdbserver test,
2 messages are produced when launching the command
target remote | vgdb
A message output by vgdb:
relaying data between gdb and process <pid>
(this message is read by GDB from the vgdb pipe, and re-output
on stderr)
and a message produced by GDB:
Remote debugging using | ./vgdb
GDB 8.0 changes the order in which the above messages are output.
This causes 2 tests to fail, as the 'relaying' line appears
then in a part of the output deleted by a filter script.
To avoid this, change the filter scripts to always remove
this 'relaying line', which is not particularly interesting to check.
All the .exp files containining such a 'relaying' line are updated
accordingly.
This has been tested with various gdb versions (7.5, 7.7, 7.12, 8.0)
on amd64 and/or ppc64.
Thanks to Mark Wielaard, which helped to investigate this problem
by bisecting the GDB patches in GDB 8.0 causing this change of
behaviour.
Mark Wielaard [Sat, 17 Jun 2017 13:49:22 +0000 (13:49 +0000)]
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.
Mark Wielaard [Fri, 16 Jun 2017 09:33:35 +0000 (09:33 +0000)]
ppc64 doesn't compile test_isa_2_06_partx.c without VSX support
The #ifdef HAS_VSX guard is wrongly placed. It makes the standard
include headers not be used. Causing a build failure. Fix by moving
the #ifdef HAS_VSX after the standard includes.
Mark Wielaard [Tue, 6 Jun 2017 09:03:03 +0000 (09:03 +0000)]
Fix pub_tool_basics.h build issue with g++ 4.4.7.
g++ 4.4.7 doesn't accept union field initializers:
In file included from ../../include/pub_tool_vki.h:50,
from valgrind_cpp_test.cpp:13:
../../include/vki/vki-linux.h: In function ‘vki_cmsghdr* __vki_cmsg_nxthdr(void*, __vki_kernel_size_t, vki_cmsghdr*)’:
../../include/vki/vki-linux.h:673: error: expected primary-expression before ‘.’ token
Assign value after declaration which works for any g++ version.
Julian Seward [Thu, 1 Jun 2017 05:46:54 +0000 (05:46 +0000)]
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.
Ivo Raisr [Wed, 31 May 2017 06:19:50 +0000 (06:19 +0000)]
Split test cases from none/tests/amd64/cet_nops
into three different files with regards to using
fs prefix, gs prefix or no fs/gs prefix.
Pertains to BZ#379525.
Mark Wielaard [Wed, 24 May 2017 15:59:53 +0000 (15:59 +0000)]
Force removal of include/vgversion.h.tmp in make_or_upd_vgversion_h.
When someone created a read only src dir and builds in a separate build
dir then the original read only vgversion.h is copied from the src dir
into the build dir as vgversion.h.tmp (also read only). It could then
not be removed again in the auxprogs/make_or_upd_vgversion_h script.
Julian Seward [Wed, 24 May 2017 13:42:33 +0000 (13:42 +0000)]
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.
Julian Seward [Mon, 22 May 2017 08:50:07 +0000 (08:50 +0000)]
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).
Compile fb_test_amd64 only if adx instructions can be compiled
Note: this just unbreaks the build on avx + non_adx capable systems
(such as gcc farm gcc20).
adx capable system should probably be better handled:
* ./tests/x86_amd64_features cannot check for adx flag
(so fb_test_amd64 is run if compiled and system is avx capable, which
might give problems if gcc/as can compile the test, but the cpu
cannot execute adx instructions)
* on an adx capable system, a native run of cpuid tells it is adx capable
but under valgrind, cpuid reports the valgrind synthetic cpu is not adx
capable.
Mark Wielaard [Thu, 18 May 2017 08:39:21 +0000 (08:39 +0000)]
Protect vgversion.h in a tarball from getting deleted by make clean
Create a file vgversion_dist.h in the tarball.
This file is not deleted by make clean
Change auxprogs/make_or_upd_vgversion_h to use vgversion_dist.h if it is
available.
Add some missing quotes to auxprogs/make_or_upd_vgversion_h
Mark Wielaard [Wed, 17 May 2017 20:38:18 +0000 (20:38 +0000)]
Fix vgversion.h generation for builddir != srcdir.
Make sure to include the builddir include directory to find the
generated vgversion.h. Make include/vgversion.h a .PHONY target
so it always gets regenerated even if the file is already there.
Make sure to run svnversion in the srcdir.
Carl Love [Wed, 17 May 2017 20:11:32 +0000 (20:11 +0000)]
PPC64, ISA 3.0 fixes
- Fix mffs instruction, FPSCR, C_FPCC field access is not
working correctly.
- Fix xscmpexpdp again still had a bug.
- Remove duplicate tests from test_isa_3_0.c
- Comment out he tests for the new ISA 3.0B instructions. There
seem to be some issues between the simulator and early HW that
need to be sorted out.
Ivo Raisr [Wed, 17 May 2017 11:06:53 +0000 (11:06 +0000)]
Fix test fb_test_amd64.
Follow up to r16372.
The test is now built if the compiler understands AVX
instructions. The test is executed if the host speaks AVX
is well. Finally bogus printf format flags were fixed as
they caused the output to be inconsistent on Linux and Solaris.
Ivo Raisr [Tue, 16 May 2017 08:22:51 +0000 (08:22 +0000)]
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.
Julian Seward [Tue, 16 May 2017 06:20:26 +0000 (06:20 +0000)]
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.
Petar Jovanovic [Mon, 15 May 2017 14:56:22 +0000 (14:56 +0000)]
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.
Julian Seward [Sun, 14 May 2017 07:56:41 +0000 (07:56 +0000)]
Add a test for amd64 basic instructions, with particular emphasis on testing
condition codes. This is originally by Fabrice Bellard (GPL2+'d), with MD5
support from Alexander Peslyak (public domain) and has been extended to cover
ADOX and ADCX as per bug #360415.
The program generates more than 800MB of output, which it MD5 sums, so the final
MD5 sum serves as the pass/fail check. It takes roughly a minute to run.
Fix mempool2 test
mempool2 test was using a wrong address for the pool arguments
in the client requests VALGRIND_MEMPOOL_FREE.
So, instead of testing what it was supposed to test (e.g. reading
memory from a freed mempool block), this was all causing
an illegal memory pool address.
So, fix the calls, and add a specific test to verify the illegal
mempool address.
Ivo Raisr [Fri, 12 May 2017 17:18:05 +0000 (17:18 +0000)]
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>
Ivo Raisr [Fri, 12 May 2017 01:16:01 +0000 (01:16 +0000)]
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>
Bart Van Assche [Thu, 11 May 2017 03:07:11 +0000 (03:07 +0000)]
tests: Remove exception specifications
Exception specifications are a deprecated feature in C++11 and gcc 7
complains about these specifications. Hence remove these specifications.
This patch avoids that gcc reports the following:
warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]