Date: Fri, 2 Oct 2009 14:42:49 GMT From: Stanislav Sedov <stas@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 169130 for review Message-ID: <200910021442.n92EgnCw029743@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=169130 Change 169130 by stas@stas_yandex on 2009/10/02 14:42:33 - Add the workaround for memcheck's mprotect issue. Memcheck tracking scheme doesn't allow to mark memory bytes as unaddressable and defined simultaneously so if we mark them unaccessible on mprotect with PROT_NONE we loose any information on definiteness. So don't alter flags at all of permissions get decreased and operate only on unaccessible bytes if additional read/write permissions were granted. Affected files ... .. //depot/projects/valgrind/memcheck/mc_main.c#6 edit Differences ... ==== //depot/projects/valgrind/memcheck/mc_main.c#6 (text+ko) ==== @@ -1635,13 +1635,38 @@ } } +static void make_mem_defined_if_unaddressable ( Addr a, SizeT len ) +{ + SizeT i; + UChar vabits2; + DEBUG("make_mem_defined_if_unaddressable(%p, %llu)\n", a, (ULong)len); + for (i = 0; i < len; i++) { + vabits2 = get_vabits2( a+i ); + if (vabits2 == VA_BITS2_NOACCESS) { + set_vabits2(a+i, VA_BITS2_DEFINED); + if (UNLIKELY(MC_(clo_mc_level) >= 3)) { + MC_(helperc_b_store1)( a+i, 0 ); /* clear the origin tag */ + } + } + } +} + /* Track changes in the virtual memory space. */ static void track_perms_change( Addr a, SizeT len, Bool rr, Bool ww, Bool xx ) { +/* if (!(rr || ww)) MC_(make_mem_noaccess) ( a, len ); - MC_(make_mem_defined) ( a, len ); +*/ + /* + * Valgrind's memory management implementation is brain-damaged + * so we can't mark memory as unaccessible but defined :-( + * Thus we don't alter it if the new bits indicate the range + * as unaccessible and only change access bits for unaccessible + * bytes if permissions were given + */ + make_mem_defined_if_unaddressable ( a, len ); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910021442.n92EgnCw029743>
