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
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 [Tue, 20 Jun 2017 17:55:13 +0000 (17:55 +0000)]
Bug 381274 powerpc too chatty even with --sigill-diagnostics=no.
Even with valgrind --sigill-diagnostics=no (or -q) guest_ppc_toIR.c
will report various cases why it didn't handle an instruction. e.g.
disInstr(ppc): found the Power 8 instruction 0x10000508 that can't be
handled by Valgrind on this host. This instruction requires a host
that supports Power 8 instructions.
After which valgrind will generate a SIGILL. But in case the user uses
-q or --sigill-diagnostics=no they aren't interested in that diagnostics.
For example openssl will try some power 8 instructions while initializing
and catch the SIGILL if not supported without issue.
Guard those cases with if (sigill_diag) like the generic decode_failure.
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.
Carl Love [Wed, 17 May 2017 20:09:46 +0000 (20:09 +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.
Petar Jovanovic [Tue, 16 May 2017 15:21:35 +0000 (15:21 +0000)]
mips: rewrite parts of mips_dirtyhelper_rdhwr
The idea behind this change is to be less dependent on build-flags, and
more dependent on runtime environment.
So, if the code is compiled for mips32r1, it should be able to execute
mips32r2 code if the platforms supports it.