|
From: <sv...@va...> - 2006-02-14 11:37:52
|
Author: sewardj
Date: 2006-02-14 11:37:41 +0000 (Tue, 14 Feb 2006)
New Revision: 5647
Log:
Ensure memory acquired from sys_brk() really is zeroed. Fixes #121893.
Modified:
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/docs/internals/3_1_BUGSTATUS.txt
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2006-02-13 18:16:41 UTC (=
rev 5646)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2006-02-14 11:37:41 UTC (=
rev 5647)
@@ -947,6 +947,23 @@
if (seg && seg->hasT)
VG_(discard_translations)( newbrk, VG_(brk_limit) - newbrk,=20
"do_brk(shrink)" );
+ /* Since we're being lazy and not unmapping pages, we have to
+ zero out the area, so that if the area later comes back into
+ circulation, it will be filled with zeroes, as if it really
+ had been unmapped and later remapped. Be a bit paranoid and
+ try hard to ensure we're not going to segfault by doing the
+ write - check both ends of the range are in the same segment
+ and that segment is writable. */
+ if (seg) {
+ /* pre: newbrk < VG_(brk_limit)=20
+ =3D> newbrk <=3D VG_(brk_limit)-1 */
+ NSegment* seg2;
+ vg_assert(newbrk < VG_(brk_limit));
+ seg2 =3D VG_(am_find_nsegment)( VG_(brk_limit)-1 );
+ if (seg2 && seg =3D=3D seg2 && seg->hasW)
+ VG_(memset)( (void*)newbrk, 0, VG_(brk_limit) - newbrk );
+ }
+
VG_(brk_limit) =3D newbrk;
return newbrk;
}
Modified: trunk/docs/internals/3_1_BUGSTATUS.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/docs/internals/3_1_BUGSTATUS.txt 2006-02-13 18:16:41 UTC (rev 5=
646)
+++ trunk/docs/internals/3_1_BUGSTATUS.txt 2006-02-14 11:37:41 UTC (rev 5=
647)
@@ -53,9 +53,9 @@
120277 unimplemented PPC floating point instructions: fres, fctid,
fctidz, frsqrte
=20
+v5647 pending 121893 calloc does not always zero memory
=20
=20
-
don't forget:
Dave Nomura extra suppression (dev, Tue Jan 17 00:14:30 2006)
Control-Z bug
|