From: Julian Seward Date: Fri, 26 Jul 2002 10:52:48 +0000 (+0000) Subject: Only run __libc_freeres() when valgrinding. It may do invalid free()s X-Git-Tag: svn/VALGRIND_1_0_0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f5ab3f6c279075727251ade5e16fe1d8f369bac;p=thirdparty%2Fvalgrind.git Only run __libc_freeres() when valgrinding. It may do invalid free()s which cause the low-level memory manager to crash. When valgrinding that's all protected, but not when cachegrinding etc. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@537 --- diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 43b018917a..0ad56b10c5 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -1377,8 +1377,22 @@ VgSchedReturnCode VG_(scheduler) ( void ) then run VG_(__libc_freeres_wrapper). That quits by doing VG_USERREQ__LIBC_FREERES_DONE, and at that point we really exit. To be safe we nuke all other threads - currently running. */ + currently running. + + If not valgrinding (cachegrinding, etc) don't do this. + __libc_freeres does some invalid frees which crash + the unprotected malloc/free system. */ + if (VG_(threads)[tid].m_eax == __NR_exit + && !VG_(clo_instrument)) { + if (VG_(clo_trace_syscalls) || VG_(clo_trace_sched)) { + VG_(message)(Vg_DebugMsg, + "Caught __NR_exit; quitting"); + } + return VgSrc_ExitSyscall; + } + if (VG_(threads)[tid].m_eax == __NR_exit) { + vg_assert(VG_(clo_instrument)); if (0 || VG_(clo_trace_syscalls) || VG_(clo_trace_sched)) { VG_(message)(Vg_DebugMsg, "Caught __NR_exit; running __libc_freeres()"); diff --git a/vg_scheduler.c b/vg_scheduler.c index 43b018917a..0ad56b10c5 100644 --- a/vg_scheduler.c +++ b/vg_scheduler.c @@ -1377,8 +1377,22 @@ VgSchedReturnCode VG_(scheduler) ( void ) then run VG_(__libc_freeres_wrapper). That quits by doing VG_USERREQ__LIBC_FREERES_DONE, and at that point we really exit. To be safe we nuke all other threads - currently running. */ + currently running. + + If not valgrinding (cachegrinding, etc) don't do this. + __libc_freeres does some invalid frees which crash + the unprotected malloc/free system. */ + if (VG_(threads)[tid].m_eax == __NR_exit + && !VG_(clo_instrument)) { + if (VG_(clo_trace_syscalls) || VG_(clo_trace_sched)) { + VG_(message)(Vg_DebugMsg, + "Caught __NR_exit; quitting"); + } + return VgSrc_ExitSyscall; + } + if (VG_(threads)[tid].m_eax == __NR_exit) { + vg_assert(VG_(clo_instrument)); if (0 || VG_(clo_trace_syscalls) || VG_(clo_trace_sched)) { VG_(message)(Vg_DebugMsg, "Caught __NR_exit; running __libc_freeres()");