62 Commits

Author SHA1 Message Date
Julian Seward
1fd197db11 Add a replacement for strcasestr, along with test case. Fixes #282979.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12187
2011-10-21 08:07:13 +00:00
Florian Krohm
dc608b4b58 Declare _exit as "noreturn". This will avoid a GCC warning.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12104
2011-10-05 14:36:00 +00:00
Julian Seward
ef5296e445 arm_linux_android: intercept __dl_strcmp and __dl_strlen in
/system/bin/linker, for the usual reason.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12054
2011-09-26 20:20:19 +00:00
Julian Seward
8885c4e740 Add initial support for Mac OS X 10.7 (Lion). Tracked by bug #275168.
* configure.in support

* new supp file darwin11.supp

* comment out many intercepts in mc_replace_strmem.c and
  vg_replace_malloc.c that are apparently unnecessary for Darwin

* add minimal handling for the following new syscalls and mach traps:
    mach_port_set_context
    task_get_exception_ports
    getaudit_addr
    psynch_mutexwait
    psynch_mutexdrop
    psynch_cvbroad
    psynch_cvsignal
    psynch_cvwait
    psynch_rw_rdlock
    psynch_rw_wrlock
    psynch_rw_unlock
    psynch_cvclrprepost

* wqthread_hijack on amd64-darwin: deal with
  tst->os_state.pthread having an apparently different offset,
  which caused an assertion failure

* m_debuginfo: for 32 bit processes on Lion, use the DebugInfoFSM
  cleanup added in r12041/12042 to handle apparently new dyld
  behaviour, which is to map text areas r-- first and only
  vm_protect them later to r-x.



The following cleanups remain to be done

* remove apparently pointless, commented out wrapper macro
  invokations in mc_replace_strmem.c, eg

  //MEMMOVE(VG_Z_DYLD,        memmove)

  (or determine that they are still necessary, and uncomment)


* ditto in vg_replace_malloc.c, plus general VGO_darwin cleanups
  there


* write proper syscall wrappers for
    mach_port_set_context
    task_get_exception_ports
    getaudit_addr
    psynch_mutexwait
    psynch_mutexdrop
    psynch_cvbroad
    psynch_cvsignal
    psynch_cvwait
    psynch_rw_rdlock
    psynch_rw_wrlock
    psynch_rw_unlock
    psynch_cvclrprepost
  These are currently just no-ops and may be causing Memcheck to
  report false undef-value errors


* figure out why it doesn't work properly unless built with gcc-4.2 on
  Lion.

  gcc-4.2 is the "normal" gcc (i686-apple-darwin11-gcc-4.2.1).  Plain
  gcc is the hybrid gcc-front-end clang-back-end thing
  (i686-apple-darwin11-llvm-gcc-4.2).  Whereas on Snow Leopard, plain
  gcc is the normal gcc.

  The symptoms of the failure are that wqthread_hijack in
  syswrap-amd64-linux.c hits this /*NOTREACHED*/ vg_assert(0); right
  at the end (you need a pretty complex threaded app to trigger this),
  which makes me think that either ML_(wqthread_continue_NORETURN) or
  call_on_new_stack_0_1 do return, which they are not expected to.


* figure out if some of the uninitialised value errors reported in
  system libraries on are caused by Memcheck being confused by LLVM
  generated code, as per bug #242137



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12043
2011-09-21 08:43:08 +00:00
Julian Seward
0e8736e529 * whitespace changes
* move MEMCPY(NONE, ZuintelZufastZumemcpy) to the correct ifdef;
  it got put in the wrong place by r12009 a couple of hours ago.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12010
2011-09-05 22:18:13 +00:00
Julian Seward
4bc0e6e01e For intercepts in libc and the dynamic linker (ld.so or dyld), split
the Linux and Darwin definitions so they are in completely separate
ifdefs -- iow, remove any definitions that are common to both.  This
gives some duplication, but the upside is that it is now possible to
edit the Darwin intercepts without fear of breaking the Linux ones.
This will be important when it comes to supporting OSX 10.7.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12009
2011-09-05 20:39:57 +00:00
Julian Seward
a9fc7fe5c3 x86-linux: don't add redirections for strchr/index in ld.so since they
are already hardwiredly-redirected at startup, and so these are
redundant.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11992
2011-08-18 13:49:48 +00:00
Julian Seward
e1567da7c5 Extend the behavioural-equivalence-class mechanism for redirection
functions to include the ability to give a priority to each function,
as well as a tag indicating its behavioural class.  Add logic in
m_redir.c to resolve conflicting redirections with the same eclass but
different priorities by preferring the redirection with the higher
priority.  Use all of the above in mc_replace_strmem.c, to cause a
conflict between redirections for "memcpy" and "memcpy@GLIBC_2.2.5" to
be resolved in favour of the latter (the non-overlap-checking
version).

This is all related to the massive swamp that is #275284.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11991
2011-08-18 13:09:55 +00:00
Tom Hughes
3cc26a2ef6 Don't compare src and dst to work out which direction to iterate
in for a memcpy/memmove if the length is zero. Fixes #268563.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11990
2011-08-18 08:10:20 +00:00
Julian Seward
1f13aa82f1 Redirect memcpy@@GLIBC_2.14 differently from memcpy@GLIBC_2.2.5, so as
to retain overlap checks for the former whilst skipping them for the
latter.  Pertains to #275284.  (Tom Hughes, tom@compton.nu)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11988
2011-08-17 21:25:50 +00:00
Julian Seward
6c61d1be73 Fix for #275284 (initial fix, at least). Will break OSX; fix
to follow.

* add behavioural eclass tags for most functions in
  mc_replace_strmem.c and vg_replace_malloc.c.

* add a wrapper for strspn()  (see bug 270925)

* coregrind/m_redir.c: add logic to use eclass tags for
  resolving conflicting redirections.  Improve debug
  printing in that situation.

* mc_replace_strmem.c: add a wrapper for "__GI___strcasecmp_l".
  Gark.  Is this correct?  Does __GI___strcasecmp_l behave the
  same as __GI_strcasecmp_l and strcasecmp_l ?



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11985
2011-08-16 21:45:28 +00:00
Julian Seward
8941601fef Un-break the build on most platforms following r11888. Oops.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11889
2011-07-12 13:50:59 +00:00
Julian Seward
5eabf446b4 Fix up preload code so that on Android it doesn't try to call anything
else -- that seems to give a runtime link failure.  In particular,
avoid calling _exit, getpagesize or __libc_freeres.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11887
2011-07-12 13:33:00 +00:00
Julian Seward
ad7de5b336 Delete the AIX5 port. The last release this worked for is 3.4.1,
and then only on AIX 5.2 and 5.3.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11842
2011-06-28 07:25:29 +00:00
Bart Van Assche
9a36fe677e Get rid of the remaining "set but not used" warnings reported by gcc 4.6 by
swapping the roles of the VALGRIND_DO_CLIENT_REQUEST() and
VALGRIND_DO_CLIENT_REQUEST_EXPR() macros. Also, many __attribute__((unused))
declarations on variables have been eliminated. Closes #269778.

Note: so far this patch has been tested on x86/Linux, amd64/Linux and
ppc64/Linux but not yet on any other supported CPU/OS combination.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11755
2011-05-15 07:04:03 +00:00
Julian Seward
9c6d0dc9c9 Fix up most but not all warnings generated by gcc-4.6 about
dead assignments ("[-Wunused-but-set-variable]").



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11673
2011-03-28 16:26:42 +00:00
Tom Hughes
d0687af4c6 Rework the strcasecmp stuff a little, based on Jakub Jelinek's patch
on bug #256600 because the original version turned out to somewhat
fragile across different glibc versions.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11479
2010-11-12 10:40:20 +00:00
Tom Hughes
8051104c57 Add replacements for strcasecmp and related functions which have
hyper-optimised versions which defeat valgrind in recent versions
of glibc.

Fixes #256600 based on patch from Dmitry Djachenko.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11478
2010-11-12 10:03:13 +00:00
Julian Seward
d866af8d34 Change the replacement for memcpy to a vectorised version that does
word copies whenever possible.  This drastically reduces the number of
memory references Memcheck has to process and speeds up a test program
that does repeated memcpys of large blocks by a factor of 4 or more.
Also add a vectorised version of memset.

The memcpy version is also constructed with a view to be used in
exp-ptrcheck, so it can copy areas of memory without losing
pointer-identity shadow data, as happens when doing all copies at a
byte granularity.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11288
2010-08-24 09:05:52 +00:00
Julian Seward
b2113a567d Add in comments a (validated) strspn replacement, should it become
necessary.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11270
2010-08-20 18:24:16 +00:00
Julian Seward
9a8dd3161a Add intercepts for strstr, strpbrk, strcspn. These are needed for
glibc-2.11 when running on SSE4-enabled (virtual) CPUs, for the usual
reason: to avoid ultra-optimised routines using the SSE 4.2 PCMPxSTRx
instructions.  I would not be surprised if it turned out that strspn
was required, but I haven't seen a need for it so far.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11268
2010-08-19 13:22:34 +00:00
Julian Seward
9b0574dff8 Update copyright dates to 2010.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11121
2010-05-03 21:37:12 +00:00
Tom Hughes
00d987f91a Add support for ELF indirect functions. These are symbols of
type STT_GNU_IFUNC which, instead of pointing directly at the
function, point at a routine which will return the address of
the real function. Redirection of indirect functions is handled
by valgrind as follows:

  - When a redirection specification matches an indirect
    function symbol an active redirection is added in the
    normal way, but with the isIFunc flag set.

  - When a call is made to an address which matches an
    active redirection with the isIFunc flag set the call
    is redirected, but not to the target address of the
    redirection - instead it is sent to a small wrapper
    routine that is preloaded into the client.

  - The wrapper routine calls the original client routine
    and collects the result, which it reports to valgrind
    using a client request, and then returns the result to
    the caller.

  - When valgrind gets the client request it looks up the
    active redirection for the indirect function and then
    adds a new active redirection which redirects from the
    address returned by the indirection function to the
    redirection target. This new redirection does not have
    the isIFunc flag set so behaves as a normal redirection.

In addition to the above we also add a few new redirections to
memcheck to capture internal calls made by glibc to things like
strlen, as these internal calls do not go through the indirect
function and instead go direct to the chosen implementation.

Based on a patch from Dodji Seketeli and comments from Jakub
Jelinek, this commit closes bug 206013.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10920
2009-10-29 09:27:11 +00:00
Nicholas Nethercote
5dfe01a847 With the recent VG_(message) change,
VALGRIND_{PRINTF,PRINTF_BACKTRACE,INTERNAL_PRINTF} were no longer appending
newlines.  This meant that --trace-malloc=yes spewed everything onto a
single line, among other things.

Rather than adding the newline back in, I chose to offically change their
behaviour to not add the newlines, as this is more flexible (and the reason
for the underlying VG_(message) change).  I updated all the relevant places
I could find.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10694
2009-08-03 01:38:56 +00:00
Nicholas Nethercote
07045477ca Merge the DARWIN branch onto the trunk.
I tried using 'svn merge' to do the merge but it did a terrible job and
there were bazillions of conflicts.  So instead I just took the diff between
the branch and trunk  at r10155, applied the diff to the trunk, 'svn add'ed
the added files (no files needed to be 'svn remove'd) and committed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10156
2009-05-28 01:53:07 +00:00
Nicholas Nethercote
57a42692d9 Don't compile Linux-only redirects on non-Linux platforms.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9745
2009-05-04 04:20:02 +00:00
Nicholas Nethercote
2001629c3f Updated copyright years.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9344
2009-03-10 22:02:09 +00:00
Nicholas Nethercote
947f9faaba Merge part of r9129 (factor out duplicated Z-encodings of names) from the
DARWIN branch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9130
2009-02-10 04:23:41 +00:00
Julian Seward
5679a22410 Update copyright dates ("200X-2007" --> "200X-2008").
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7398
2008-02-11 11:34:59 +00:00
Julian Seward
5dfa7202f4 Intercept memcpy on 64-bit ld.so's.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7350
2008-01-15 08:42:56 +00:00
Julian Seward
953b8549d7 Changes to make Memcheck work sanely on recent incarnations of AIX 5.3:
* add a few more syscall wrappers, and fix a couple of buggy ones

* intercept strcmp et al in a few more libraries



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7249
2007-11-29 03:08:32 +00:00
Julian Seward
c7fbd65201 Make Memcheck work sanely on AIX5.3 (again):
* Don't intercept putenv/getenv/setenv.  Causes a lot of whinging
  about missing TOC pointers.

* Add 'strcmp' to the bundle of 4 functions intercepted in all
  objects.

* xlc now seems to route calls through to malloc_common, free_common,
  calloc_common, realloc_common, memalign_common in libc.  Intercept
  those names too.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7241
2007-11-27 11:42:47 +00:00
Julian Seward
fd7a6b5363 Intercept __memcpy_chk, which appears in glibc-2.6.1. Also fix some
backslash uglyness.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7155
2007-11-13 20:52:29 +00:00
Julian Seward
acf1f14d7a Merge from CGTUNE branch:
r6738:
Unroll memset; apparently is popular in some places (kpdf).




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6780
2007-08-25 23:25:00 +00:00
Dirk Mueller
40de8b88ed wrap env related functions to be able to track undefined
values better


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6706
2007-04-19 09:47:32 +00:00
Julian Seward
51c70bbf4c Back out r6640; I'm pretty sure it is the wrong thing to do now.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6648
2007-03-14 11:55:28 +00:00
Julian Seward
e9a5b6ad4e It appears glibc-2.5's getenv() function steps along environment
strings in 16-bit chunks, which can cause false errors in some cases
(sigh).  So do the usual thing and replace it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6640
2007-03-11 13:00:34 +00:00
Julian Seward
7efbc7213b Track recent XArray changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6625
2007-02-27 22:36:14 +00:00
Julian Seward
4cb951158d Add an intercept for __memmove_chk (another glibc 2.5 artefact)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6608
2007-02-23 09:03:26 +00:00
Julian Seward
5c1eb23d61 __stpcpy_chk: sync with Dirk's original proposal, and show origins
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6556
2007-01-28 06:32:01 +00:00
Julian Seward
dfad5c3381 Intercept __stpcpy_chk. (Dirk Mueller)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6553
2007-01-27 00:49:44 +00:00
Julian Seward
2ee6ebe4bf Intercept mempcpy also in ld.so.1.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6537
2007-01-18 18:01:45 +00:00
Julian Seward
648b3b2707 Intercept _intel_fast_memcpy in the main executable. Partial fix for
#139667.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6526
2007-01-16 21:42:28 +00:00
Julian Seward
172505c978 Update copyright dates.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6488
2007-01-08 06:01:59 +00:00
Julian Seward
b76cb7d9e6 Replace bcmp in ld.so.1.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6479
2007-01-06 06:30:48 +00:00
Julian Seward
20b41c0c23 Provide a replacement for mempcpy.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6469
2006-12-31 18:55:56 +00:00
Julian Seward
daf075a233 Intercept/replace glibc-2.5's __strcpy_chk function for the usual
reasons: it reads word-sized chunks from memory and so produces lots
of errors in SuSE 10.2 (amd64).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6462
2006-12-31 00:22:30 +00:00
Nicholas Nethercote
d162731a2c Completely overhauled the internals of Memcheck's error handling. All the
different error kinds were reusing the same struct for storing their
details.  Each one used some but not all the fields, and the AddrInfo was
similar, and it was very confusing.

So I changed MC_Error and AddrInfo to be tagged unions, like Vex's IRExpr and
IRStmt types.  The resulting code is a little more verbose but much easier
to understand.  I also split up several error kinds, which also made things
simpler.  The user-visible behaviour is identical except for a couple of
very minor things that I've documented in the NEWS file for the 3.3.0
release.

Ideally I'd get rid of the Addr and Char* fields in the core Error type,
which are not always used, and do them similarly within tools.  But that
would require changing the core/tool interface, so I'm leaving it for the
moment.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6402
2006-12-16 00:54:12 +00:00
Julian Seward
3c6f899f71 Merge r6111:
AIX5 changes.  Perhaps this isn't quite the right place to add a
sqrt() replacement.  Hmm.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6255
2006-10-17 01:27:13 +00:00
Julian Seward
1213e9bcf7 Merge (from 3_2_BRANCH) r6048 (SuSE 10.1 (ppc32) minor fixes)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6051
2006-09-11 20:33:55 +00:00