From: Julian Seward Date: Wed, 15 May 2002 22:25:47 +0000 (+0000) Subject: More new-signal-hacks fixes. X-Git-Tag: svn/VALGRIND_1_0_3~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=930d862210a47b322b47ff54d7b1bb7a4a1e3226;p=thirdparty%2Fvalgrind.git More new-signal-hacks fixes. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@272 --- diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 7ed6a9a2be..d1d792a000 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -1529,6 +1529,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) static void cleanup_after_thread_exited ( ThreadId tid ) { + vki_ksigset_t irrelevant_sigmask; vg_assert(VG_(is_valid_or_empty_tid)(tid)); vg_assert(VG_(threads)[tid].status == VgTs_Empty); /* Mark its stack no-access */ @@ -1538,6 +1539,7 @@ void cleanup_after_thread_exited ( ThreadId tid ) /* Forget about any pending signals directed specifically at this thread, and get rid of signal handlers specifically arranged for this thread. */ + VG_(block_all_host_signals)( &irrelevant_sigmask ); VG_(handle_SCSS_change)( False /* lazy update */ ); } @@ -2507,6 +2509,10 @@ void do_pthread_sigmask ( ThreadId tid, VG_(do_pthread_sigmask_SCSS_upd) ( tid, vki_how, newmask, oldmask ); + if (newmask && VG_(clo_instrument)) { + VGM_(make_readable)( (Addr)newmask, sizeof(vki_ksigset_t) ); + } + /* Success. */ SET_EDX(tid, 0); } diff --git a/coregrind/vg_signals.c b/coregrind/vg_signals.c index dea4551378..ca4b58d598 100644 --- a/coregrind/vg_signals.c +++ b/coregrind/vg_signals.c @@ -557,8 +557,9 @@ void do_setmask ( ThreadId tid, if (VG_(clo_trace_signals)) VG_(message)(Vg_DebugMsg, - "do_setmask: tid = %d (0 means ALL), how = %d (%s), set = %p", + "do_setmask: tid = %d (%d means ALL), how = %d (%s), set = %p", tid, + VG_INVALID_THREADID, how, how==VKI_SIG_BLOCK ? "SIG_BLOCK" : ( how==VKI_SIG_UNBLOCK ? "SIG_UNBLOCK" : ( diff --git a/tests/pth_signal2.c b/tests/pth_signal2.c index 19976f7268..9e6f24ee70 100644 --- a/tests/pth_signal2.c +++ b/tests/pth_signal2.c @@ -27,7 +27,7 @@ int mean, samples, total; void *report_stats(void *p) { - int caught; + int caught, i; sigset_t sigs_to_catch; /* Identify our thread */ @@ -41,12 +41,6 @@ void *report_stats(void *p) * handle it. */ - /* JRS 13 May 2002: this has a race condition, which is obvious if - you fire SIGUSR1s at it fast enough -- once sigwait returns, - there is no hander whilst it does the rest of the loop, so if a - signal arrives then, the program is killed, since that's the - default action for SIGUSR1. */ - /* set this thread's signal mask to block out SIGUSR1 */ sigemptyset(&sigs_to_catch); sigaddset(&sigs_to_catch, SIGUSR1); @@ -58,6 +52,11 @@ void *report_stats(void *p) mean = total/samples; printf("\nreport_stats(): mean = %d, samples = %d\n", mean, samples); pthread_mutex_unlock(&stats_lock); + + /* Delay for a while so it's obvious whether or not SIGUSR1 is + still blocked here (it should be). */ + // for (i = 0; i < 100000; i++) ; + } return NULL; } diff --git a/vg_scheduler.c b/vg_scheduler.c index 7ed6a9a2be..d1d792a000 100644 --- a/vg_scheduler.c +++ b/vg_scheduler.c @@ -1529,6 +1529,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) static void cleanup_after_thread_exited ( ThreadId tid ) { + vki_ksigset_t irrelevant_sigmask; vg_assert(VG_(is_valid_or_empty_tid)(tid)); vg_assert(VG_(threads)[tid].status == VgTs_Empty); /* Mark its stack no-access */ @@ -1538,6 +1539,7 @@ void cleanup_after_thread_exited ( ThreadId tid ) /* Forget about any pending signals directed specifically at this thread, and get rid of signal handlers specifically arranged for this thread. */ + VG_(block_all_host_signals)( &irrelevant_sigmask ); VG_(handle_SCSS_change)( False /* lazy update */ ); } @@ -2507,6 +2509,10 @@ void do_pthread_sigmask ( ThreadId tid, VG_(do_pthread_sigmask_SCSS_upd) ( tid, vki_how, newmask, oldmask ); + if (newmask && VG_(clo_instrument)) { + VGM_(make_readable)( (Addr)newmask, sizeof(vki_ksigset_t) ); + } + /* Success. */ SET_EDX(tid, 0); } diff --git a/vg_signals.c b/vg_signals.c index dea4551378..ca4b58d598 100644 --- a/vg_signals.c +++ b/vg_signals.c @@ -557,8 +557,9 @@ void do_setmask ( ThreadId tid, if (VG_(clo_trace_signals)) VG_(message)(Vg_DebugMsg, - "do_setmask: tid = %d (0 means ALL), how = %d (%s), set = %p", + "do_setmask: tid = %d (%d means ALL), how = %d (%s), set = %p", tid, + VG_INVALID_THREADID, how, how==VKI_SIG_BLOCK ? "SIG_BLOCK" : ( how==VKI_SIG_UNBLOCK ? "SIG_UNBLOCK" : (