VG_(track_new_mem_startup) ( mc_new_mem_startup );
VG_(track_new_mem_stack_signal)( make_mem_undefined_w_tid );
+ // We assume that brk()/sbrk() does not initialise new memory. Is this
+ // accurate? John Reiser says:
+ //
+ // 0) sbrk() can *decrease* process address space. No zero fill is done
+ // for a decrease, not even the fragment on the high end of the last page
+ // that is beyond the new highest address. For maximum safety and
+ // portability, then the bytes in the last page that reside above [the
+ // new] sbrk(0) should be considered to be uninitialized, but in practice
+ // it is exceedingly likely that they will retain their previous
+ // contents.
+ //
+ // 1) If an increase is large enough to require new whole pages, then
+ // those new whole pages (like all new pages) are zero-filled by the
+ // operating system. So if sbrk(0) already is page aligned, then
+ // sbrk(PAGE_SIZE) *does* zero-fill the new memory.
+ //
+ // 2) Any increase that lies within an existing allocated page is not
+ // changed. So if (x = sbrk(0)) is not page aligned, then
+ // sbrk(PAGE_SIZE) yields ((PAGE_SIZE -1) & -x) bytes which keep their
+ // existing contents, and an additional PAGE_SIZE bytes which are zeroed.
+ // ((PAGE_SIZE -1) & x) of them are "covered" by the sbrk(), and the rest
+ // of them come along for the ride because the operating system deals
+ // only in whole pages. Again, for maximum safety and portability, then
+ // anything that lives above [the new] sbrk(0) should be considered
+ // uninitialized, but in practice will retain previous contents [zero in
+ // this case.]"
+ //
+ // In short:
+ //
+ // A key property of sbrk/brk is that new whole pages that are supplied
+ // by the operating system *do* get initialized to zero.
+ //
+ // As for the portability of all this:
+ //
+ // sbrk and brk are not POSIX. However, any system that is a derivative
+ // of *nix has sbrk and brk because there are too many softwares (such as
+ // the Bourne shell) which rely on the traditional memory map (.text,
+ // .data+.bss, stack) and the existence of sbrk/brk.
+ //
+ // So we should arguably observe all this. However:
+ // - The current inaccuracy has caused maybe one complaint in seven years(?)
+ // - Telying on the zeroed-ness of whole brk'd pages is pretty grotty... I
+ // doubt most programmers know the above information.
+ // So I'm not terribly unhappy with marking it as undefined. --njn.
VG_(track_new_mem_brk) ( make_mem_undefined_w_tid );
VG_(track_new_mem_mmap) ( mc_new_mem_mmap );
new_override.stderr.exp new_override.stdout.exp new_override.vgtest \
noisy_child.vgtest noisy_child.stderr.exp noisy_child.stdout.exp \
null_socket.stderr.exp null_socket.vgtest \
- origin1-yes.vgtest origin1-yes.stdout.exp \
- origin1-yes.stderr.exp origin1-yes.stderr.exp-darwin \
+ origin1-yes.vgtest origin1-yes.stdout.exp origin1-yes.stderr.exp \
origin2-not-quite.vgtest origin2-not-quite.stdout.exp \
origin2-not-quite.stderr.exp \
origin3-no.vgtest origin3-no.stdout.exp \
}
// Heap segment (brk), uninitialised
- // Nb: on Darwin, sbrk() is implemented via vm_allocate() which always
- // zeroes its allocated memory. So we use a separate .exp file for Darwin,
- // but we add an extra printf on Darwin only so that it cannot be
- // successfully matched on non-Darwin platforms.
-#if defined(VGO_darwin)
+ // CURRENTLY DISABLED. Why?
+ // - On Darwin, sbrk() is implemented via vm_allocate() which always zeroes
+ // its allocated memory. For a while we used use a separate .exp file
+ // for Darwin, but we add an extra printf on Darwin only so that it
+ // cannot be successfully matched on non-Darwin platforms.
+ // - On Ubuntu 9.04 configured with --enable-only32bit, the brk symbol
+ // shows up as "???"
+ // - Our current treatment of brk is suspect; whole new pages allocated
+ // with brk should arguably be marked defined -- see the big comment
+ // above track_new_mem_brk() in memcheck/mc_main.c.
+//#if defined(VGO_darwin)
fprintf(stderr, "\nUndef 7 of 8 (brk)\n");
- fprintf(stderr, "\n(no complaint; sbrk initialises memory on Darwin)\n");
-#else
- {
- int* ptr_to_new_brk_limit = sbrk(4096);
- int undef_brk_int = *ptr_to_new_brk_limit;
- fprintf(stderr, "\nUndef 7 of 8 (brk)\n");
- x += (undef_brk_int == 0x12345678 ? 15 : 26);
- }
-#endif
+// fprintf(stderr, "\n(no complaint; sbrk initialises memory on Darwin)\n");
+ fprintf(stderr, "\n(currently disabled)\n");
+//#else
+// {
+// int* ptr_to_new_brk_limit = sbrk(4096);
+// int undef_brk_int = *ptr_to_new_brk_limit;
+// fprintf(stderr, "\nUndef 7 of 8 (brk)\n");
+// x += (undef_brk_int == 0x12345678 ? 15 : 26);
+// }
+//#endif
// User block, marked as undefined
{
Undef 7 of 8 (brk)
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:101)
- Uninitialised value was created
- at 0x........: brk (in /...libc...)
- by 0x........: sbrk (in /...libc...)
- by 0x........: main (origin1-yes.c:98)
+(currently disabled)
Undef 8 of 8 (MAKE_MEM_UNDEFINED)
Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:110)
+ at 0x........: main (origin1-yes.c:117)
Uninitialised value was created by a client request
- at 0x........: main (origin1-yes.c:108)
+ at 0x........: main (origin1-yes.c:115)
Def 1 of 3
+++ /dev/null
-
-Undef 1 of 8 (stack, 32 bit)
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:37)
- Uninitialised value was created by a stack allocation
- at 0x........: main (origin1-yes.c:23)
-
-Undef 2 of 8 (stack, 32 bit)
-
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:49)
- Uninitialised value was created by a stack allocation
- at 0x........: main (origin1-yes.c:23)
-
-Undef 3 of 8 (stack, 64 bit)
-
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:56)
- Uninitialised value was created by a stack allocation
- at 0x........: main (origin1-yes.c:23)
-
-Undef 4 of 8 (mallocd, 32-bit)
-
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:64)
- Uninitialised value was created by a heap allocation
- at 0x........: malloc (vg_replace_malloc.c:...)
- by 0x........: main (origin1-yes.c:61)
-
-Undef 5 of 8 (realloc)
-
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:76)
- Uninitialised value was created by a heap allocation
- at 0x........: realloc (vg_replace_malloc.c:...)
- by 0x........: main (origin1-yes.c:71)
-
-Undef 6 of 8 (MALLOCLIKE_BLOCK)
-
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:85)
- Uninitialised value was created by a heap allocation
- at 0x........: main (origin1-yes.c:82)
-
-Undef 7 of 8 (brk)
-
-(no complaint; sbrk initialises memory on Darwin)
-
-Undef 8 of 8 (MAKE_MEM_UNDEFINED)
-
-Conditional jump or move depends on uninitialised value(s)
- at 0x........: main (origin1-yes.c:110)
- Uninitialised value was created by a client request
- at 0x........: main (origin1-yes.c:108)
-
-Def 1 of 3
-
-Def 2 of 3
-
-Def 3 of 3