diff --git a/NEWS b/NEWS index 146251a10..b68d3c49d 100644 --- a/NEWS +++ b/NEWS @@ -52,11 +52,12 @@ where XXXXXX is the bug number as listed below. 354797 Added vbit tester support for PPC 64 isa 2.07 iops 354933 Fix documentation of --kernel-variant=android-no-hw-tls option 355188 valgrind should intercept all malloc related global functions -355455 expected stderr of test cases wrapmalloc and wrapmallocstatic overconstrained +355455 stderr.exp of test cases wrapmalloc and wrapmallocstatic overconstrained 355454 do not intercept malloc related symbols from the runtime linker 356044 Dwarf line info reader misinterprets is_stmt register n-i-bz Fix incorrect (or infinite loop) unwind on RHEL7 x86 32 bits +n-i-bz massif --pages-as-heap=yes does not report peak caused by mmap+munmap Release 3.11.0 (22 September 2015) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/massif/ms_main.c b/massif/ms_main.c index e55a774b7..021d79095 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -1816,10 +1816,13 @@ void ms_unrecord_page_mem( Addr a, SizeT len ) Addr end; tl_assert(VG_IS_PAGE_ALIGNED(len)); tl_assert(len >= VKI_PAGE_SIZE); + // Unrecord the first page. This might be the peak, so do a snapshot. + unrecord_block((void*)a, /*maybe_snapshot*/True); + a += VKI_PAGE_SIZE; + // Then unrecord the remaining pages, but without snapshots. for (end = a + len - VKI_PAGE_SIZE; a < end; a += VKI_PAGE_SIZE) { unrecord_block((void*)a, /*maybe_snapshot*/False); } - unrecord_block((void*)a, /*maybe_snapshot*/True); } //------------------------------------------------------------// diff --git a/massif/tests/Makefile.am b/massif/tests/Makefile.am index 531d8e6e1..4b69bfc7e 100644 --- a/massif/tests/Makefile.am +++ b/massif/tests/Makefile.am @@ -24,6 +24,7 @@ EXTRA_DIST = \ long-names.post.exp long-names.stderr.exp long-names.vgtest \ long-time.post.exp long-time.stderr.exp long-time.vgtest \ malloc_usable.stderr.exp malloc_usable.vgtest \ + mmapunmap.post.exp mmapunmap.stderr.exp mmapunmap.vgtest \ new-cpp.post.exp new-cpp.stderr.exp new-cpp.vgtest \ no-stack-no-heap.post.exp no-stack-no-heap.stderr.exp no-stack-no-heap.vgtest \ null.post.exp null.stderr.exp null.vgtest \ @@ -61,6 +62,7 @@ check_PROGRAMS = \ insig \ long-names \ long-time \ + mmapunmap \ malloc_usable \ new-cpp \ null \ diff --git a/massif/tests/mmapunmap.c b/massif/tests/mmapunmap.c new file mode 100644 index 000000000..4bb4e5a18 --- /dev/null +++ b/massif/tests/mmapunmap.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include +#include "tests/sys_mman.h" + +int main() +{ + void *m; + + m = mmap(NULL, 80 * 1000 * 1024, + PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, + -1, 0); + munmap(m, 80 * 1000 * 1024); + return 0; +} diff --git a/massif/tests/mmapunmap.post.exp b/massif/tests/mmapunmap.post.exp new file mode 100644 index 000000000..50e5c6ea9 --- /dev/null +++ b/massif/tests/mmapunmap.post.exp @@ -0,0 +1 @@ + n0: 81920000 0x........: main (mmapunmap.c:11) diff --git a/massif/tests/mmapunmap.stderr.exp b/massif/tests/mmapunmap.stderr.exp new file mode 100644 index 000000000..e69de29bb diff --git a/massif/tests/mmapunmap.vgtest b/massif/tests/mmapunmap.vgtest new file mode 100644 index 000000000..696965841 --- /dev/null +++ b/massif/tests/mmapunmap.vgtest @@ -0,0 +1,6 @@ +prog: mmapunmap +vgopts: --pages-as-heap=yes --threshold=30.0 -q +vgopts: --stacks=no --time-unit=B --depth=8 --massif-out-file=massif.out +vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element +post: grep -A3 -e =peak massif.out | grep -e 'main (mmapunmap.c:11)' | ../../tests/filter_addresses +# cleanup: rm massif.out