From: Julian Seward Date: Sun, 30 Jun 2002 10:57:30 +0000 (+0000) Subject: cleanup_after_thread_exited: also clean up the waiting_fds table on thread X-Git-Tag: svn/VALGRIND_1_0_3~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bf10a361875034842b0fa135230d17ffc2b5155;p=thirdparty%2Fvalgrind.git cleanup_after_thread_exited: also clean up the waiting_fds table on thread disappearance. This fixes an assertion failure to do with thread nukage on fork(): vg_scheduler.c:936 (poll_for_ready_fds): Assertion `vgPlain_is_valid_tid(tid)' failed. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@478 --- diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 796ca7ee73..076b160ef5 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -1493,6 +1493,7 @@ void make_thread_jump_to_cancelhdlr ( ThreadId tid ) static void cleanup_after_thread_exited ( ThreadId tid ) { + Int i; vki_ksigset_t irrelevant_sigmask; vg_assert(VG_(is_valid_or_empty_tid)(tid)); vg_assert(VG_(threads)[tid].status == VgTs_Empty); @@ -1505,6 +1506,13 @@ void cleanup_after_thread_exited ( ThreadId tid ) this thread. */ VG_(block_all_host_signals)( &irrelevant_sigmask ); VG_(handle_SCSS_change)( False /* lazy update */ ); + + /* Clean up the waiting_fd table */ + for (i = 0; i < VG_N_WAITING_FDS; i++) { + if (vg_waiting_fds[i].tid == tid) { + vg_waiting_fds[i].fd = -1; /* not in use */ + } + } } diff --git a/vg_scheduler.c b/vg_scheduler.c index 796ca7ee73..076b160ef5 100644 --- a/vg_scheduler.c +++ b/vg_scheduler.c @@ -1493,6 +1493,7 @@ void make_thread_jump_to_cancelhdlr ( ThreadId tid ) static void cleanup_after_thread_exited ( ThreadId tid ) { + Int i; vki_ksigset_t irrelevant_sigmask; vg_assert(VG_(is_valid_or_empty_tid)(tid)); vg_assert(VG_(threads)[tid].status == VgTs_Empty); @@ -1505,6 +1506,13 @@ void cleanup_after_thread_exited ( ThreadId tid ) this thread. */ VG_(block_all_host_signals)( &irrelevant_sigmask ); VG_(handle_SCSS_change)( False /* lazy update */ ); + + /* Clean up the waiting_fd table */ + for (i = 0; i < VG_N_WAITING_FDS; i++) { + if (vg_waiting_fds[i].tid == tid) { + vg_waiting_fds[i].fd = -1; /* not in use */ + } + } }