]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix stupid bug arising as a result of the call to __libc_freeres() at the
authorJulian Seward <jseward@acm.org>
Fri, 16 Aug 2002 18:51:49 +0000 (18:51 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 16 Aug 2002 18:51:49 +0000 (18:51 +0000)
end, in which the return value of the process was not correctly propagated.

MERGE TO HEAD

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_1_0_BRANCH@594

vg_include.h
vg_main.c
vg_scheduler.c

index 0d38c92332e4b868f90b24cf6c80a275cdd44010..1e831c3faca7b8cec02b044373ddc26619e62b74 100644 (file)
@@ -1569,6 +1569,11 @@ extern UInt VG_(current_epoch);
 /* This is the ThreadId of the last thread the scheduler ran. */
 extern ThreadId VG_(last_run_tid);
 
+/* This is the argument to __NR_exit() supplied by the first thread to
+   call that syscall.  We eventually pass that to __NR_exit() for
+   real. */
+extern UInt VG_(exitcode);
+
 
 /* --- Counters, for informational purposes only. --- */
 
index 5cce13d2e8604380168906a1757ab4d2f8fbebf2..2634af27dd3b9657c15966089838646ce1f91302 100644 (file)
--- a/vg_main.c
+++ b/vg_main.c
@@ -339,6 +339,11 @@ UInt VG_(current_epoch) = 0;
 /* This is the ThreadId of the last thread the scheduler ran. */
 ThreadId VG_(last_run_tid) = 0;
 
+/* This is the argument to __NR_exit() supplied by the first thread to
+   call that syscall.  We eventually pass that to __NR_exit() for
+   real. */
+UInt VG_(exitcode) = 0;
+
 
 /* ---------------------------------------------------------------------
    Counters, for informational purposes only.
@@ -1222,7 +1227,7 @@ void VG_(main) ( void )
          vg_assert(tst->status == VgTs_Runnable);
          /* The thread's %EBX will hold the arg to exit(), so we just
             do exit with that arg. */
-         VG_(exit)( tst->m_ebx );
+         VG_(exit)( VG_(exitcode) );
          /* NOT ALIVE HERE! */
          VG_(panic)("entered the afterlife in vg_main() -- ExitSyscall");
          break; /* what the hell :) */
index 0ad56b10c5f54a72d853033fbc61ed2fad9ad926..1275511271a1473f884ae8132319c54f366d1b4f 100644 (file)
@@ -1382,6 +1382,11 @@ VgSchedReturnCode VG_(scheduler) ( void )
                If not valgrinding (cachegrinding, etc) don't do this.
                __libc_freeres does some invalid frees which crash
                the unprotected malloc/free system. */
+
+            /* If __NR_exit, remember the supplied argument. */
+            if (VG_(threads)[tid].m_eax == __NR_exit)
+               VG_(exitcode) = VG_(threads)[tid].m_ebx; /* syscall arg1 */
+
             if (VG_(threads)[tid].m_eax == __NR_exit 
                 && !VG_(clo_instrument)) {
                if (VG_(clo_trace_syscalls) || VG_(clo_trace_sched)) {