66 Commits

Author SHA1 Message Date
Nicholas Nethercote
bbfc62ea8c Fixed bug in overlap check in strncpy() -- it was assuming the src was 'n'
bytes longs, when it could be shorter, which could cause false positives.

Added an example of this to the regtest.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1983
2003-11-02 17:43:27 +00:00
Nicholas Nethercote
6afbad116a Added a regtest that uses pthreads -- there weren't any.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1966
2003-10-30 09:11:03 +00:00
Jeremy Fitzhardinge
32c9b08d6e We expect new output with the syscalls changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1924
2003-10-14 21:11:29 +00:00
Nicholas Nethercote
4a64211e76 Whoops, forgot to commit changes to Makefile.am when I added the 'new_nothrow'
test.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1901
2003-10-10 11:01:44 +00:00
Nicholas Nethercote
e5cca0566e Added interceptions for:
operator new(unsigned, std::nothrow_t const&)
  operator new[](unsigned, std::nothrow_t const&)

because they weren't being intercepted, and called malloc(), which caused bogus
mismatch errors.

Added a regression test for it, too.

MERGE TO STABLE (although the change to vg_replace_malloc.c won't quite be a
cut and paste job, because of prior changes made to it in the head
but not the stable branch;  merge will still be easy, though)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1899
2003-10-09 15:40:38 +00:00
Nicholas Nethercote
bc7e854aee The name-mangled versions of __builtin_new() and __builtin_vec_new() now
don't just call the unmangled versions, but do the appropriate stuff
themselves directly (this was necessary for Massif).  This means that stack
traces for them have one fewer function.  And I was able to gather up several
very similar functions into a macro, reducing the amount of code, which was
nice.  Had to update one regtest's expected output accordingly.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1875
2003-09-30 16:52:47 +00:00
Nicholas Nethercote
a2edbd2aad Fix broken regtest.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1857
2003-09-29 14:45:44 +00:00
Nicholas Nethercote
0db1843d96 Made Addrcheck distinguish between invalid reads and invalid writes (previously
was just saying "invalid memory access").

Added a regression test for this, for memcheck and addrcheck.  Also made
Addrcheck use Memcheck's fprw regtest.  Was able to remove the not-very-useful
'true' test for Addrcheck now that it has a couple of real tests.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1815
2003-09-05 23:29:33 +00:00
Nicholas Nethercote
aae64e3630 Forgot to add these files for the writev regression test.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1814
2003-09-05 23:02:38 +00:00
Nicholas Nethercote
138ada5bc2 Fixed readv() and writev() so they won't fall over if they are given a negative
count.  Added a regression test for it.

Updated the basic test stderr filter to strip out line numbers from
vg_intercept.c

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1812
2003-09-04 21:57:45 +00:00
Nicholas Nethercote
7b2a49544e Fixed brk(); it was almost completely broken.
Added a regression test for it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1810
2003-09-04 20:57:51 +00:00
Nicholas Nethercote
c2bfdc506c Changed the behaviour of realloc() in Memcheck, Addrcheck and Helgrind.
Previously, when realloc() was asked to make a block bigger, the ExeContext
describing where that block was allocated was increased;  however, if the block
became smaller or stayed the same size, the original ExeContext remained.  This
is correct in one way (that's where the memory manager actually parcelled out
the block) but it's not very intuitive.  This commit changes things so the
ExeContext of a block is always changed upon realloc().  I added a regression
test for it too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1783
2003-07-24 17:39:59 +00:00
Nicholas Nethercote
aca466757f Changed behaviour of VALGRIND_COUNT_LEAKS slightly. Previously, the numbers it
returned (bytes leaked, dubious, etc) were incremented for every leak check
performed.  So if you called VALGRIND_DO_LEAK_CHECK twice in a row, the totals
would be updated twice by the same amount.  This was a bit silly.  So now
COUNT_LEAKS just returns the numbers of bytes leaked found from the previous
leak check.  I even updated the docs, and changed the regression test so old
version fail but the new version passes (by doing two DO_LEAK_CHECKS in a row).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1778
2003-07-22 22:03:58 +00:00
Nicholas Nethercote
ca84f991d3 Added overlap checking to Addrcheck, mostly just moving things around. In
particular, renamed mc_replace_strmem.c as mac_replace_strmem.c;  the 'mac'
prefix indicates it's shared between Memcheck and Addrcheck.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1774
2003-07-22 09:12:33 +00:00
Julian Seward
a22d206634 Make sure all the regression tests get included in the tarball created
by 'make dist'.  Being the release dude is so exciting!


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1761
2003-07-16 19:03:10 +00:00
Julian Seward
c31032d863 Run -q
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1757
2003-07-13 22:35:55 +00:00
Julian Seward
ad483fa714 Add test for correct errno handling in threaded programs.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1755
2003-07-13 11:13:37 +00:00
Julian Seward
3fd7b59db2 Dodge around more glibc variants.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1740
2003-07-08 00:13:51 +00:00
Julian Seward
4cdfda823b Fix a whole lot more regression tests on Red Hat 7.3.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1739
2003-07-07 23:56:10 +00:00
Julian Seward
13a725160b Make more tests glibc-2.X robust.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1737
2003-07-07 00:43:34 +00:00
Julian Seward
d7c4c25b32 Try and make different gcc versions agree on source locations. Sigh.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1736
2003-07-07 00:32:44 +00:00
Julian Seward
85c213c457 Make some more tests more robust against glibc differences.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1735
2003-07-07 00:23:23 +00:00
Julian Seward
32f9ee0000 A regression test for the new VALGRIND_{GET,SET}_VBITS macros.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1734
2003-07-07 00:03:52 +00:00
Julian Seward
e835a84d53 Make these work on Red Hat 7.3 (by giving -q)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1733
2003-07-06 23:43:01 +00:00
Julian Seward
9b6314fd56 Run the test with -q so that it works both on glibc-2.2 and 2.3. The
problem if -q is not used is that the lines "malloc/free: 1 allocs, 0
frees, 8 bytes allocated." have different counts depending on the
glibc version.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1732
2003-07-06 23:24:18 +00:00
Nicholas Nethercote
136c7fba2c Fixed cpuid regtest, which was broken by the switch to using the machine's real
CPUID.

Also added filters to Makefiles where missing;  "make regtest" was broken
within distributions created using "make dist", now fixed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1709
2003-06-29 10:12:58 +00:00
Nicholas Nethercote
83ef1ca2ed Some Makefile.am changes. Lots of them affected:
- changed deprecated INCLUDES variable to AM_CPPFLAGS

- moved the -DVG_LIBDIR definition from AM_CFLAGS into AM_CPPFLAGS

- generally neatened them up a bit -- removed old commented out stuff, fixed a
  couple of other minor things

Everything works for me, hopefully it won't break things for anyone else...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1680
2003-06-12 14:13:05 +00:00
Dirk Mueller
3a22ea2dbc fix expected output
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1664
2003-06-01 20:04:10 +00:00
Dirk Mueller
7607301e2e some ignores
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1658
2003-05-28 01:02:46 +00:00
Nicholas Nethercote
40571c6f66 Added VALGRIND_MALLOCLIKE_BLOCK and VALGRIND_FREELIKE_BLOCK which allow you to
use a custom-allocator and detect almost as many errors as you could detect if
you used malloc/new/new[].  (eg. leaks detected, free errors, free mismatch,
etc).

Had to fiddle with mac_malloc_wrappers.c a bit to factor out the appropriate
code to be called from the client request handling code.  Also had to add a
new element `MAC_AllocCustom' to the MAC_AllocKind type.

Also added a little documentation, and a regression test.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1643
2003-05-20 16:38:24 +00:00
Julian Seward
8ab5a6a18f Whoops, forgot this on last commit.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1617
2003-05-05 16:33:53 +00:00
Julian Seward
46aa527659 Fixed problems with reg tests for frames below main(), which were different
under some setups.

Also fixed problem with Cachegrind tests, by filtering out P4s'
warning message.

Also fixed 'mismatches'.

------------------------------------------------------------


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1616
2003-05-05 16:18:51 +00:00
Nicholas Nethercote
d43c0e3942 Made 'tronical' and 'pushfpopf' less likely to fail by filtering their stderr
output more vigorously.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1612
2003-05-05 09:23:12 +00:00
Nicholas Nethercote
9b3ef6f767 Improved filtering so that 'overlap' test less likely to fail.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1611
2003-05-05 09:09:08 +00:00
Nicholas Nethercote
91998793ac wibble
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1585
2003-05-02 17:54:33 +00:00
Nicholas Nethercote
1810431e9d wibble
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1583
2003-05-02 17:40:43 +00:00
Nicholas Nethercote
8c22ec62d9 Made memcpy()-et-al-overlap errors fully fledged errors, suppressible,
recordable, etc.  Thanks to Tom Hughes <thh@cyberscience.com> for the patch.

Also fixed a minor bug in the reporting -- the src/dst pointers given for
strncat(), strcpy(), strcat().

And I updated the relevent regression test.

And I even added relevant documentation.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1582
2003-05-02 17:24:29 +00:00
Nicholas Nethercote
2566d12bc0 Added regression tests for recent bug fix involving accept(), recvfrom() and
getsockopt() being allowed to received a NULL buffer.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1581
2003-05-02 16:19:10 +00:00
Dirk Mueller
92ca30fb7f fix sigaltstack regression test to be more glibc-version tolerant
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1552
2003-04-24 00:40:38 +00:00
Dirk Mueller
9728df8ca7 the error is in line 13, not in line 15
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1546
2003-04-23 17:03:34 +00:00
Nicholas Nethercote
994eea589d Fixed minor boo-boo
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1536
2003-04-22 20:58:02 +00:00
Nicholas Nethercote
1b48c55fc5 Added two client requests: VALGRIND_COUNT_ERRORS and VALGRIND_COUNT_LEAKS.
The first returns the number of errors found so far, and is a core request.
The second returns the number of bytes found
reachable/dubious/leaked/suppressed by all leak checks so far, for Memcheck and
Addrcheck.

Both are useful for using Valgrind in regression test suites where multiple
tests are present in a single file -- one can run Valgrind with no output
(using --logfile-fd=-1) and use the requests after each test to determine if
any errors happened.

Had to rename and make public vg_n_errs_found --> VG_(n_errs_found) to do so.
Nb: leak errors are not counted as errors for the purposes of
VALGRIND_COUNT_ERRORS.  This was decided as the best thing to do after
discussion with Olly Betts, who original suggested these changes.

Pulled out common client request code shared between Memcheck and Addrcheck.

Added a regression test for this.

Added some documentation too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1533
2003-04-21 13:24:40 +00:00
Dirk Mueller
02b63b3ba8 reapply automake fixes. make check will now generate the binaries which
are only required for regression testing.

If this breaks something, please mail me first instead of reverting.
Thank you.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1530
2003-04-17 17:00:43 +00:00
Nicholas Nethercote
d2168aca37 wibble
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1527
2003-04-16 20:09:47 +00:00
Nicholas Nethercote
982fa6481a -----------------------------------------------------------------------------
overview
-----------------------------------------------------------------------------
Previously Valgrind had its own versions of malloc() et al that replaced
glibc's.  This is necessary for various reasons for Memcheck, but isn't needed,
and was actually detrimental, to some other skins.  I never managed to treat
this satisfactorily w.r.t the core/skin split.

Now I have.  If a skin needs to know about malloc() et al, it must provide its
own replacements.  But because this is not uncommon, the core provides a module
vg_replace_malloc.c which a skin can link with, which provides skeleton
definitions, to reduce the amount of work a skin must do.  The skeletons handle
the transfer of control from the simd CPU to the real CPU, and also the
--alignment, --sloppy-malloc and --trace-malloc options.  These skeleton
definitions subsequently call functions SK_(malloc), SK_(free), etc, which the
skin must define;  in these functions the skin can do the things it needs to do
about tracking heap blocks.

For skins that track extra info about malloc'd blocks -- previously done with
ShadowChunks -- there is a new file vg_hashtable.c that implements a
generic-ish hash table (using dodgy C-style inheritance using struct overlays)
which allows skins to continue doing this fairly easily.

Skins can also replace other functions too, eg. Memcheck has its own versions
of strcpy(), memcpy(), etc.

Overall, it's slightly more work now for skins that need to replace malloc(),
but other skins don't have to use Valgrind's malloc(), so they're getting a
"purer" program run, which is good, and most of the remaining rough edges from
the core/skin split have been removed.

-----------------------------------------------------------------------------
details
-----------------------------------------------------------------------------
Moved malloc() et al intercepts from vg_clientfuncs.c into vg_replace_malloc.c.
Skins can link to it if they want to replace malloc() and friends;  it does
some stuff then passes control to SK_(malloc)() et al which the skin must
define.  They can call VG_(cli_malloc)() and VG_(cli_free)() to do the actual
allocation/deallocation.  Redzone size for the client (the CLIENT arena) is
specified by the static variable VG_(vg_malloc_redzone_szB).
vg_replace_malloc.c thus represents a kind of "mantle" level service.

To get automake to build vg_replace_malloc.o, had to resort to a similar trick
as used for the demangler -- ask for a "no install" library (which is never
used) to be built from it.

Note that all malloc, calloc, realloc, builtin_new, builtin_vec_new, memalign
are now aware of --alignment, when running on simd CPU or real CPU.

This means the new_mem_heap, die_mem_heap, copy_mem_heap and ban_mem_heap
events no longer exist, since the core doesn't control malloc() any more, and
skins can watch for these events themselves.

This required moving all the ShadowChunk stuff out of the core, which meant
the sizeof_shadow_block ``need'' could be removed, yay -- it was a horrible
hack.  Now ShadowChunks are done with a generic HashTable type, in
vg_hashtable.c, which skins can "inherit from" (in a dodgy C-only fashion by
using structs with similar layouts).  Also, the free_list stuff was all moved
as a part of this.  Also, VgAllocKind was moved out of core into
Memcheck/Addrcheck and renamed MAC_AllocKind.

Moved these options out of core into vg_replace_malloc.c:
    --trace-malloc
    --sloppy-malloc
    --alignment

The alternative_free ``need'' could go, too, since Memcheck is now in complete
control of free(), yay -- another horribility.

The bad_free and free_mismatch events could go too, since they're now not
detected by core, yay -- yet another horribility.

Moved malloc() et al wrappers for Memcheck out of vg_clientmalloc.c into
mac_malloc_wrappers.c.  Helgrind has its own wrappers now too.

Introduced VG_USERREQ__CLIENT_CALL[123] client requests.  When a skin function
is operating on the simd CPU, this will call a given function and run it on the
real CPU.  The macros VG_NON_SIMD_CALL[123] in valgrind.h present a cleaner
interface to actually use.  Also introduce analogues of these that pass 'tst'
from the scheduler as the first arg to the called function -- needed for
MC_(client_malloc)() et al.

Fiddled with USERREQ_{MALLOC,FREE} etc. in vg_scheduler.c; they call
SK_({malloc,free})() which by default call VG_(cli_malloc)() -- can't call
glibc's malloc() here.  All the other default SK_(calloc)() etc. instantly
panic; there's a lock variable to ensure that the default SK_({malloc,free})()
are only called from the scheduler, which prevents a skin from forgetting to
override SK_({malloc,free})().  Got rid of the unused USERREQ_CALLOC,
USERREQ_BUILTIN_NEW, etc.

Moved special versions of strcpy/strlen, etc, memcpy() and memchr() into
mac_replace_strmem.c -- they are only necessary for memcheck, because the
hyper-optimised normal glibc versions confuse it, and for memcpy() etc. overlap
checking.

Also added dst/src overlap checks to strcpy(), memcpy(), strcat().  They are
reported not as proper errors, but just with single line warnings, as for silly
args to malloc() et al;  this is mainly because they're on the simulated CPU
and proper error handling would be a pain;  hopefully they're rare enough to
not be a problem.  The strcpy check is done after the copy, because it would
require counting the length of the string beforehand.  Also added strncpy() and
strncat(), which have overlap checks too.  Note that addrcheck doesn't do
overlap checking.

Put USERREQ__LOGMESSAGE in vg_skin.h to do the overlap check error messages.

After removing malloc() et al and strcpy() et al out of vg_clientfuncs.c, moved
the remaining three things (sigsuspend, VG_(__libc_freeres_wrapper),
__errno_location) into vg_intercept.c, since it contains things that run on the
simulated CPU too.  Removed vg_clientfuncs.c altogether.

Moved regression test "malloc3" out of corecheck into memcheck, since corecheck
no longer looks for silly (eg. negative) args to malloc().

Removed the m_eip, m_esp, m_ebp fields from the `Error' type.  They were being
set up, and then read immediately only once, only if GDB attachment was done.
So now they're just being held in local variables.  This saves 12 bytes per
Error.

Made replacement calloc() check for --sloppy-malloc;  previously it didn't.

Added "silly" negative size arg check to realloc(), it didn't have one.

Changed VG_(read_selfprocmaps)() so it can parse the file directly, or from a
previously read buffer.  Buffer can be filled with the new
VG_(read_selfprocmaps_contents)().  Using this at start-up to snapshot
/proc/self/maps before the skins do anything, and then parsing it once they
have done their setup stuff.  Skins can now safely call VG_(malloc)() in
SK_({pre,post}_clo_init)() without the mmap'd superblock erroneously being
identified as client memory.

Changed the --help usage message slightly, now divided into four sections: core
normal, skin normal, core debugging, skin debugging.  Changed the interface for
the command_line_options need slightly -- now two functions, VG_(print_usage)()
and VG_(print_debug_usage)(), and they do the printing themselves, instead of
just returning a string -- that's more flexible.

Removed DEBUG_CLIENTMALLOC code, it wasn't being used and was a pain.

Added a regression test testing leak suppressions (nanoleak_supp), and another
testing strcpy/memcpy/etc overlap warnings (overlap).

Also changed Addrcheck to link with the files shared with Memcheck, rather than
#including the .c files directly.

Commoned up a little more shared Addrcheck/Memcheck code, for the usage
message, and initialisation/finalisation.

Added a Bool param to VG_(unique_error)() dictating whether it should allow
GDB to be attached; for leak checks, because we don't want to attach GDB on
leak errors (causes seg faults).  A bit hacky, but it will do.

Had to change lots of the expected outputs from regression files now that
malloc() et al are in vg_replace_malloc.c rather than vg_clientfuncs.c.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1524
2003-04-15 13:03:23 +00:00
Nicholas Nethercote
0756a50bc3 Removed support for the 1.0.X series from the regression test suite -- this
was present from before the core/skin split, which is now dead.  Means the
script is slightly simpler, and we can dispense with lots of expected
foo.stderr.hd files.

Also undid accidental change to required Automake version in main Makefile.am
from my last commit, whoops.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1518
2003-04-08 00:47:05 +00:00
Julian Seward
2d2a15abbf Change a bunch of AM_CFLAGS, AM_CXXFLAGS to CFLAGS, CXXFLAGS.
The AM_ versions totally break compilation on RH6.2.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1447
2003-02-28 23:22:44 +00:00
Nicholas Nethercote
18199aae8a Added a stderr filter for new_override, that removes the exact numbers for
malloc, because different glibc versions seem to allocate different amounts of
memory.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1446
2003-02-26 10:16:02 +00:00
Julian Seward
b891391739 Make CXXFLAGS be the same as AM_CXXFLAGS, so the correct options are
used to build the regression tests.  I don't know if this is really
the correct way to fix this problem.  I don't understand why
AM_CXXFLAGS aren't used by default for C++, seeing as how AM_CFLAGS
evidently are used for C sources.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1445
2003-02-25 23:49:46 +00:00
Dirk Mueller
8f9785b1eb fix make distcheck with newer automake
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1443
2003-02-25 01:48:15 +00:00