]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Only run __libc_freeres() when valgrinding. It may do invalid free()s
authorJulian Seward <jseward@acm.org>
Fri, 26 Jul 2002 10:52:48 +0000 (10:52 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 26 Jul 2002 10:52:48 +0000 (10:52 +0000)
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

coregrind/vg_scheduler.c
vg_scheduler.c

index 43b018917acac06b3044afd54c63d9dc14ebf4f5..0ad56b10c5f54a72d853033fbc61ed2fad9ad926 100644 (file)
@@ -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()");
index 43b018917acac06b3044afd54c63d9dc14ebf4f5..0ad56b10c5f54a72d853033fbc61ed2fad9ad926 100644 (file)
@@ -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()");