From 7b0cd3ac2884d2557a476e5010d44e60ff531846 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Thu, 2 Jun 2022 20:31:12 +0200 Subject: [PATCH] Add code that makes 1st page after brk inaccessible. Also remove FreeBSD expected. Note: this code is also mssing from Solaris and macOS initimg's. --- coregrind/m_initimg/initimg-freebsd.c | 9 +++++ memcheck/tests/dw4.stderr.exp-freebsd | 49 --------------------------- 2 files changed, 9 insertions(+), 49 deletions(-) delete mode 100644 memcheck/tests/dw4.stderr.exp-freebsd diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index 6029ffb69b..fcf05c86ac 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -986,6 +986,15 @@ void VG_(ii_finalise_image)( IIFinaliseImageInfo iifii ) /* Tell the tool that we just wrote to the registers. */ VG_TRACK( post_reg_write, Vg_CoreStartup, /*tid*/1, /*offset*/0, sizeof(VexGuestArchState)); + + /* Tell the tool about the client data segment and then kill it which will + make it inaccessible/unaddressable. */ + const NSegment *seg = VG_(am_find_nsegment)(VG_(brk_base)); + vg_assert(seg); + vg_assert(seg->kind == SkAnonC); + VG_TRACK(new_mem_brk, VG_(brk_base), seg->end + 1 - VG_(brk_base), + 1/*tid*/); + VG_TRACK(die_mem_brk, VG_(brk_base), seg->end + 1 - VG_(brk_base)); } #endif // defined(VGO_freebsd) diff --git a/memcheck/tests/dw4.stderr.exp-freebsd b/memcheck/tests/dw4.stderr.exp-freebsd deleted file mode 100644 index e396a43b8a..0000000000 --- a/memcheck/tests/dw4.stderr.exp-freebsd +++ /dev/null @@ -1,49 +0,0 @@ -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:59) - Address 0x........ is 4 bytes inside a block of size ... alloc'd - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (dw4.c:52) - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:61) - Location 0x........ is 0 bytes inside S2[0].i, - a global variable declared at dw4.c:47 - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:62) - Location 0x........ is 0 bytes inside local.i, - declared at dw4.c:51, in frame #1 of thread 1 - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:68) - Address 0x........ is in a rw- anonymous segment - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:82) - Address 0x........ is in a rw- mapped file valgrind-dw4-test.PID segment - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:87) - Address 0x........ is 0 bytes after the brk data segment limit 0x........ - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:89) - Address 0x........ is in the brk data segment 0x........-0x........ - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:91) - Address 0x........ is in the brk data segment 0x........-0x........ - -Unaddressable byte(s) found during client check request - at 0x........: croak (dw4.c:25) - by 0x........: main (dw4.c:93) - Address 0x........ is 1024 bytes after the brk data segment limit 0x........ - -- 2.47.2