From: Julian Seward Date: Thu, 2 Aug 2012 10:40:31 +0000 (+0000) Subject: Back out r12466, which stopped non-MAP_FIXED mmaps by the client on X-Git-Tag: svn/VALGRIND_3_8_0~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b3c2d6642df292560727e5bd2b499fd5f85765f;p=thirdparty%2Fvalgrind.git Back out r12466, which stopped non-MAP_FIXED mmaps by the client on Darwin from returning address zero (however insane that is). r12466 appears to cause other applications to break (TextEdit, for one). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12813 --- diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 8d76177e9c..dbafe47589 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -3547,43 +3547,11 @@ PRE(mmap) POST(mmap) { - vg_assert(SUCCESS); - /* JRS 2012 Mar 26: RES != -1 is surely not the right way to check - for success. In any case I think syswrap-main.c won't let us - get here if the syscall failed, so the check is irrelevant. See - VG_(post_syscall). */ - if (RES == -1) - return; - vg_assert(VG_IS_PAGE_ALIGNED(RES)); - - /* begin KLUDGE */ - Bool did_kludge = False; - if (ARG1 == 0 && !(ARG4 & MAP_FIXED) && RES == 0) { - /* An mmap-anonymous succeeded at address zero. This is pretty - stupid (legit, but dangerous); so repeat the mmap call so as - to get a non-zero address. Then unmap the area that the - original mmap created, and tidy up. Failure to do this is - a causative factor in - https://bugzilla.mozilla.org/show_bug.cgi?id=738034 - */ - SysRes more = VG_(am_do_mmap_NO_NOTIFY)(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); - if (!sr_isError(more)) { - Bool need_discard = False; - VG_(am_munmap_client)(&need_discard, 0, ARG2); - vg_assert(!need_discard); - SET_STATUS_from_SysRes(more); - did_kludge = True; - } - } - /* end KLUDGE */ - - ML_(notify_core_and_tool_of_mmap)(RES, ARG2, ARG3, ARG4, ARG5, ARG6); - // Try to load symbols from the region - VG_(di_notify_mmap)( (Addr)RES, False/*allow_SkFileV*/, - -1/*don't use_fd*/ ); - if (did_kludge) { - /* Be paranoid if The Kludge happens. */ - VG_(am_do_sync_check)("(MMAP_ANON_ZERO_ZERO_KLUDGE)",__FILE__,__LINE__); + if (RES != -1) { + ML_(notify_core_and_tool_of_mmap)(RES, ARG2, ARG3, ARG4, ARG5, ARG6); + // Try to load symbols from the region + VG_(di_notify_mmap)( (Addr)RES, False/*allow_SkFileV*/, + -1/*don't use_fd*/ ); } }