From: Nicholas Nethercote Date: Thu, 21 Sep 2006 15:59:30 +0000 (+0000) Subject: Add a comment about marking static memory as defined. X-Git-Tag: svn/VALGRIND_3_3_0~667 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd94343ee3cedf39e87dbda2f27d03b16d5af791;p=thirdparty%2Fvalgrind.git Add a comment about marking static memory as defined. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6083 --- diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 026356b670..98052484dc 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -2161,6 +2161,16 @@ static void mc_new_mem_startup( Addr a, SizeT len, Bool rr, Bool ww, Bool xx ) { /* Ignore the permissions, just make it defined. Seems to work... */ + // Because code is defined, initialised variables get put in the data + // segment and are defined, and uninitialised variables get put in the + // bss segment and are auto-zeroed (and so defined). + // + // It's possible that there will be padding between global variables. + // This will also be auto-zeroed, and marked as defined by Memcheck. If + // a program uses it, Memcheck will not complain. This is arguably a + // false negative, but it's a grey area -- the behaviour is defined (the + // padding is zeroed) but it's probably not what the user intended. And + // we can't avoid it. DEBUG("mc_new_mem_startup(%p, %llu, rr=%u, ww=%u, xx=%u)\n", a, (ULong)len, rr, ww, xx); MC_(make_mem_defined)(a, len);