Commit Graph

5207 Commits

Author SHA1 Message Date
Ivo Raisr
b0b7bbf30b Follow up to SVN commit r15936.
Fix the sloppy check I introduced.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15939
2016-08-17 18:05:13 +00:00
Ivo Raisr
b6224ced96 Follow up to r15936.
Kernel allocates another page after fork and we have to
keep aspacemgr's point of view consistent.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15937
2016-08-15 02:31:27 +00:00
Ivo Raisr
6260274e4e Follow recent Solaris development with respect to
SUNWDTRACE program header. Newer Solaris no longer utilizes
this program header as a scratchspace for DTrace fasttrap
provider, before libc is loaded.
For the time being, it serves as a space for initial thread
pointer.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15936
2016-08-12 22:28:50 +00:00
Petar Jovanovic
030cea68c8 mips32: add support for FPXX mode
With this patch, MIPS32 Valgrind compiled with -mfpxx can handle all types
(regarding FP_ABI flag) of MIPS32 ELFs.

- Functions arch_elf_pt_proc() and arch_check_elf() are added to elf reader
  according to linux/fs/binfmt_elf.c from Linux 4.1;
- Processing .MIPS.abiflags section and initializing appropriate FPU mode
  for MIPS32 are added;
- Emulation of prctl(GET/SET_FP_MODE) sys-calls are implemented for MIPS32.

Patch by Aleksandar Rikalo <Aleksandar.Rikalo@imgtec.com>

Related VEX change: r3243.

This implements BZ#366079.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15934
2016-08-10 14:38:10 +00:00
Julian Seward
1a2f71d6ff Reimplement pszB_to_listNo using a binary search rather than a linear search.
Unlikely as it seems, this saves a considerable number of instructions (2% of total)
on very heap-intensive code (perf/heap.c).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15926
2016-08-05 14:54:27 +00:00
Julian Seward
7c3b4bf540 Make "ashmem" and "binder" ioctls be handled properly on 64-bit ARM Android,
rather than falling through to the generic handler and being mishandled.
Fixes #360574.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15923
2016-08-04 21:11:28 +00:00
Julian Seward
f8eca86bbf Add infrastructure for detection of 32-bit ARMv8 capable CPUs (Valgrind side).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15921
2016-08-03 11:40:36 +00:00
Julian Seward
7a8129795c Fix incorrect assertion re sizeof TTEntryC on arm-linux. Fixes #362935.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15912
2016-07-21 12:47:51 +00:00
Ivo Raisr
86203023fa Set executable protection on schedctl pages only when necessary.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15903
2016-07-11 21:05:03 +00:00
Philippe Waroquiers
80dec3e514 Fix 365273 - Invalid write to stack location reported after signal handler runs
Analysis and patch by Earl Chew

Tested on x86/amd64/ppc64



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15902
2016-07-10 21:17:58 +00:00
Philippe Waroquiers
b07050d998 Fix leak in m_redir.c
See below discussion for more details.

On Sat, 2016-07-02 at 14:20 +0200, Philippe Waroquiers wrote:
> I am testing a patch (provided by Julian) that solves a false positive
> memcheck found at my work.
> 
> Testing this, I decided to run valgrind under valgrind (not done since
> a long time).
> 
> This shows a leak in many tests, the stack trace being such as:
> ==26246== 336 bytes in 21 blocks are definitely lost in loss record 72 of 141
> ==26246==    at 0x2801C01D: vgPlain_arena_malloc (m_mallocfree.c:1855)
> ==26246==    by 0x2801D616: vgPlain_arena_strdup (m_mallocfree.c:2528)
> ==26246==    by 0x2801D616: vgPlain_strdup (m_mallocfree.c:2600)
> ==26246==    by 0x2801F5AD: vgPlain_redir_notify_new_DebugInfo (m_redir.c:619)
> ==26246==    by 0x2803B650: di_notify_ACHIEVE_ACCEPT_STATE (debuginfo.c:771)
> ==26246==    by 0x2803B650: vgPlain_di_notify_mmap (debuginfo.c:1067)
> ==26246==    by 0x2806589C: vgModuleLocal_generic_PRE_sys_mmap (syswrap-generic.c:2368)
> ==26246==    by 0x2809932A: vgSysWrap_amd64_linux_sys_mmap_before (syswrap-amd64-linux.c:637)
> ==26246==    by 0x28061E11: vgPlain_client_syscall (syswrap-main.c:1906)
> ==26246==    by 0x2805E9D2: handle_syscall (scheduler.c:1118)
> ==26246==    by 0x280604A6: vgPlain_scheduler (scheduler.c:1435)
> ==26246==    by 0x2806FF87: thread_wrapper (syswrap-linux.c:103)
> ==26246==    by 0x2806FF87: run_a_thread_NORETURN (syswrap-linux.c:156)
> 
> 
> The strdup call in m_redir.c:619 was introduced by r15726.
> 
> However, I am not sure this is a bug that is introduced by this change,
> or if it just reveals a leak that was already there.
> The "very original" replacement logic did not do memory allocation for
> the replacement: see m_redir.c in valgrind 3.10.1 : it was just copying
> some chars from VG_(clo_soname_synonyms) to demangled_sopatt

Yes, it should do exactly the same as the other code paths. If
replaced_sopatt != NULL then it is an allocated string that has been
assigned to demangled_sopatt. I had assumed that would take care of the
life-time issues of the allocated string. But now that I read the code
it is indeed not so clear.

> Then in 3.11, the fixed size demangled_sopatt was changed to be
> a dynamically allocated buffer.
> The revision log 14664 that introduced this explains that the ownership of
> returned buffer is not easy. It tells at the end:
> "So the rule of thunb here is: if in doubt strdup the string."
> 
> but now we have to see when to free what, it seems ???
> 
> Any thoughts ?

So if replaced_sopatt != NULL, then demangled_sopatt contains the
allocated string, and it is then immediately copied and assigned to
spec->from_sopatt. After that it is used under check_ppcTOCs. But there
it will first be reassigned a new value through maybe_Z_demangle
(overwriting any existing string being pointed to). So for this
particular leak it seem fine to free it right after the spec[List] has
been initialized (line 642).

Cheers,

Mark



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15898
2016-07-02 18:46:23 +00:00
Mark Wielaard
08086f0855 Bug 364413 pselect sycallwrapper mishandles NULL sigmask.
Don't check or try to copy sigmask if it is NULL. The sigmask might be
given in a struct, where the length is non-zero, but the signal set
pointer is NULL.

Testcase provided by Paul Eggert <eggert@cs.ucla.edu>.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15893
2016-06-21 19:58:21 +00:00
Rhys Kidd
2ea4e5efa4 Fix tst->os_state.pthread - magic_delta assertion failure on OSX 10.11
bz#354883

Whilst I’ve seen different magic_delta values on one of my older development machines (Intel Nehalem-based), enough other users have reported success with this change.

If this causes regressions, please report your hardware details in our Bugzilla.

Regression test output on OS X 10.11

Before:

== 601 tests, 223 stderr failures, 12 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==

After:

== 601 tests, 223 stderr failures, 12 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15891
2016-06-04 15:34:56 +00:00
Mark Wielaard
6b8c5dfb75 Bug 363680 add renameat2() support
Patch written by Jann Horn <jannhorn@googlemail.com>.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15889
2016-05-31 12:16:15 +00:00
Mark Wielaard
59d79476bc Bug 363714 ppc64 missing syscalls sync, waitid and name_to/open_by_handle_at
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15888
2016-05-30 20:16:04 +00:00
Mark Wielaard
958ea4cb5b Bug #363705 arm64 missing syscall name_to_handle_at and open_by_handle_at
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15887
2016-05-30 14:17:25 +00:00
Ivo Raisr
fbaa6ad350 Solaris: Further refinement of r15882 for Solaris versions
which do not have <sys/sysnvl.h> header file.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15885
2016-05-29 12:10:58 +00:00
Ivo Raisr
d894770ee3 Solaris: Add ioctl wrappers for DINFOUSRLD and DINFOIDENT.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15884
2016-05-29 09:29:28 +00:00
Ivo Raisr
aad88ea2d0 Solaris: Add syscall modctl with several commands implemented.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15882
2016-05-28 22:05:43 +00:00
Philippe Waroquiers
268ff84f7b Document brk segment limitation, reference manual in limit reached msg.
The msg telling brk cannot be extended confuses some users
so improve the documentation and have the msg referencing the doc.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15880
2016-05-22 20:48:09 +00:00
Ivo Raisr
ffcb955c34 Solaris: Add wrapper for setparam subcode of the door syscall.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15879
2016-05-16 12:51:27 +00:00
Ivo Raisr
8ace9b4f06 Solaris ioctl: Add wrapper for I_FLUSH.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15878
2016-05-16 11:38:29 +00:00
Ivo Raisr
662eab632a Solaris ioctl: Add wrapper for I_FIND.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15877
2016-05-16 06:12:27 +00:00
Petar Jovanovic
c7d3589646 mips32: raise the limit for sizeof(TTEntryC)
Raise limit for sizeof(TTEntryC) due to 8-byte alignement requirement for
ULong on mips32 platforms. It is a follow up to the same change on ppc32
(see r15875), and it un-breaks mips32-linux (broken with r15784).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15876
2016-05-06 17:34:55 +00:00
Julian Seward
325dfcc0d9 Un-break ppc32-linux following r15784. It appears that ppc32-ELF
layout constraints are different from x86-ELF and so the assertion on
the sizeof(TTEntryC) fails on ppc32-linux.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15875
2016-04-28 15:52:01 +00:00
Julian Seward
c10a83a800 Split the structure TTEntry into hot (small) and cold (large) parts,
TTEntryH and TTEntryC.  TTEntryH is a VexGuestExtents plus one more
field.  For scenarios involving a lot of code discarding, when the
fast-path discard mechanism does not apply, this change reduces
significantly the number of LLC misses, because such discarding
involves sequentially searching the arrays of TTEntryH's.  For recent
Firefoxes the miss rate in a 6MB L3 cache is reduced by about 1/3, as
measured by /usr/bin/perf.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15874
2016-04-27 16:46:04 +00:00
Julian Seward
f0077be94b Fix indentation that gcc-6 -Wmisleading-indentation rightfully complaints about.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15873
2016-04-27 08:19:52 +00:00
Julian Seward
abf0d0a78d Fix compilation breakage on platforms that do already have a definition
for Elf{32,64}_Chdr.  This is fallout from r15868.  That commit provided
a configure test, but the resulting config.h was not included here, causing
the test results to be ignored.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15869
2016-04-24 17:11:44 +00:00
Ivo Raisr
da7df0f276 Valgrind is able to read compressed debuginfo sections in two formats:
- zlib ELF gABI format with SHF_COMPRESSED flag (gcc option -gz=zlib)
  - zlib GNU format with .zdebug sections (gcc option -gz=zlib-gnu)

Patch by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com>
Fixes BZ#303877



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15868
2016-04-23 20:28:27 +00:00
Ivo Raisr
5d4c5ae3d6 Fix Valgrind coredump when VG_(unimplemented)() is called
early during main initialization, before the threads are
created and scheduler is initialized.
Fixes BZ#362009


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15867
2016-04-23 19:35:11 +00:00
Carl Love
862031ddab PPC64, Valgrind with GDB does not display 64-bit and 128-bit registers
correctly

Forgot to add the new files to the previous commit 15864.

coregrind/m_gdbserver/power64-core2-valgrind-s1.xml
coregrind/m_gdbserver/power64-core2-valgrind-s2.xml
coregrind/m_gdbserver/power-vsx-valgrind-s1.xml
coregrind/m_gdbserver/power-vsx-valgrind-s2.xml
coregrind/m_gdbserver/power-vsx.xml

Bugzilla 360008 was opened for this issue.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15866
2016-04-22 15:03:46 +00:00
Carl Love
a30916183c PPC64, Valgrind with GDB does not display 64-bit and 128-bit registers
correctly

1)  Fix Endianess issue that was missed in the BE to LE port.  GDB was
    not displaying the contents of the 64-bit and 128-bit registers
    correctly due to an Endianess issue.

2)  Fix displaying the shadow registers for the 64-bit and 128-bit
    registers.

Bugzilla 360008 was opened for this issue.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15864
2016-04-21 18:21:26 +00:00
Ivo Raisr
eb743789cd Print arguments of DWARF extension DW_CFA_ORCL_arg_loc.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15863
2016-04-20 00:21:50 +00:00
Ivo Raisr
91f7614767 Solaris: Add syscall wrapper for sysfs(84)
Fixes BZ#361926


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15862
2016-04-19 15:57:13 +00:00
Ivo Raisr
7cd8f83b96 Follow up to bug 345307.
Passing parameter on x86 architecture was wrong in final_tidyup().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15854
2016-04-08 21:29:15 +00:00
Ivo Raisr
60a0aa1d53 Kludge for multiple .rodata sections on Solaris introduced by BZ#353802
is no longer needed. The situation with multiple ".rodata" sections existed
only between dozens of builds of Solaris 12.
Fixes BZ#360749


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15853
2016-04-08 20:38:30 +00:00
Mark Wielaard
d60fb6bdfe Bug 361354 ppc64[le]: wire up separate socketcalls system calls
Newer glibc will use separate socket related syscalls instead of using
the multiplexing socketcall systemcall. On Fedora rawhide this causes
several tests to fail.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15845
2016-04-03 20:33:11 +00:00
Ivo Raisr
5b3c2f59c5 Run __gnu_cxx::__freeres() cleanup function available
from libstdc++ when available, similar to existing __libc_freeres().
New option --run-cxx-freeres=<yes|no> can be used to change whether
this cleanup function is called or not.

Note that __gnu_cxx::__freeres() is currently available
only in gcc 6. It is not yet decided what to do about
libstdc++ from gcc 5.
Tracked under https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69945
for libstdc++.

Fixes BZ#345307 (partially).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15840
2016-03-30 17:53:03 +00:00
Ivo Raisr
beb198ca3a Fix bug 324227 also on Solaris.
We somehow overlooked this commit during development work on Solaris port
before it landed in the official repository.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15839
2016-03-30 17:36:03 +00:00
Carl Love
efb480318c Power PC Add support for ISA 3.0, part 1
The Floating-point condition code bits FPCC is bits[15:12] of the FPSCR.
The instructions fcmpu, fcmpo, dcmpu, dcmpq, dtstdc, dtstdcq, xscmpodq
and xscmpudq set the FPCC bits in addition to the BE field of the CC
register.  This support is needed by the ISA 3.0 instructions to be added.
    
Added support to emulate the modsw, moduw, modsd, modud, extswsli,
maddld, maddhd, maaddhdu, xxperm, xxpermr, vabsdub, vabsduh, vabsduw,
mtvsrws, xxextractuw, xxinsertw, xxspltib, xxbrh, xxbrw, xxbrd, xxbrq,
vpermr, vextractub, vextractuh, vextractuw, vextractd, vinsertb, vinserth,
vinsertw, vinsertd, lxvwsx, stxvb16x, stxvx, lxvb16x, lxvh8x, lxvx
instructions.

valgrind bugzilla 359767
VEX commit 3214


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15837
2016-03-29 21:28:43 +00:00
Ivo Raisr
9cb1ae2dc1 Raise the number of reserved fds in m_main.c from 10 to 12.
Fixes BZ#360752.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15835
2016-03-24 06:24:12 +00:00
Julian Seward
566759979a VG_(discard_translations):
* fix off-by-one error that forced use of the slow case unnecessarily

* change ECLASS_SHIFT from 11 to 13 so that ranges up to 8KB can fall
  within an equivalence class, and increase ECLASS_WIDTH by 1 so as to
    double the number of hash buckets (effectively).

These measures noticably improve the performance of modern Firefoxes,
since they do a lot of 4KB and 8KB discards as a result of mprotect
trickery used to implement W^X protection on JIT code pages.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15833
2016-03-21 20:04:05 +00:00
Ivo Raisr
d3eb7a8894 Add support for repository cache protocol version 31
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15831
2016-03-16 15:08:42 +00:00
Philippe Waroquiers
eb2ffd99ee Small optimisation : use preprocessor for cache stats
as the compiler does not remove the access to the not useful static vars


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15828
2016-03-12 21:38:22 +00:00
Mark Wielaard
d4ec6d9870 Bug 359503 - Add missing syscalls for aarch64 (arm64)
Enable more arm64 syscalls. ioprio_set, ioprio_get, preadv, pwritev,
vmsplice, splice, tee, waitid, clock_nanosleep and perf_event_open.
Reported and patch (mostly) by Marcin Juszkiewicz.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15826
2016-03-09 16:18:37 +00:00
Mark Wielaard
a848da57ad Add arm64 scalar test. Enable tested syscalls.
The new memcheck/tests/arm64-linux/scalar test is based on the
memcheck/tests/x86-linux/scalar test and contains all syscalls
that are also available on arm64. To make comparison of exp results
easier the order of the tested syscalls is the same as on x86.
This enables a couple extra arm64 syscalls. Part of the fix for
bug #359503 - Add missing syscalls for aarch64 (arm64).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15825
2016-03-09 16:18:36 +00:00
Mark Wielaard
eba2cff480 Use correct syscall numbers on arm64. Fix rename, dup2 and getpgrp.
We were using some wrong syscall numbers in vki-scnums-arm64-linux.h
arm64 doesn't implement a couple of old deprecated system calls like
rename, dup2, getpgrp and fork. Adjust m_libcfile.c rename and dup2
functions to use renameat (also on tilegx) and dup3 (with fcntl fallback
for bad oldfd). And in m_libcproc.c implement getpgrp as getpgid(0).
Also don't compile the fork syswrap on arm64 (it only supports clone).

In practice this only affected callgrind which was unable to rename
dump files in some cases and ELF core dumps might have contained some
bogus prstatus fields.

Related to bug #359503 - Add missing syscalls for aarch64 (arm64)
Reported by Marcin Juszkiewicz who also posted a nice overview
of system calls on different linux architectures:
https://marcin.juszkiewicz.com.pl/2016/03/05/from-a-diary-of-aarch64-porter-system-calls/

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15824
2016-03-09 16:18:34 +00:00
Ivo Raisr
912bede3dd Sanitize signal mask in ppoll and pselect syscalls
Reported and Linux patch contributed by Steven Smith <sos22@archy.org.uk>
Fixes BZ#359871



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15823
2016-03-08 09:04:48 +00:00
Ivo Raisr
728e88fa2c Solaris door: Restrict availability of REP_PROTOCOL_ENTITY_FMRI to certain repcache versions only
Follow-up for r15819.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15820
2016-03-01 12:13:24 +00:00
Ivo Raisr
e059272ce0 Solaris door: Add support for REP_PROTOCOL_ENTITY_FMRI
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15819
2016-02-29 20:20:36 +00:00