]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
More new-signal-hacks fixes.
authorJulian Seward <jseward@acm.org>
Wed, 15 May 2002 22:25:47 +0000 (22:25 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 15 May 2002 22:25:47 +0000 (22:25 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@272

coregrind/vg_scheduler.c
coregrind/vg_signals.c
tests/pth_signal2.c
vg_scheduler.c
vg_signals.c

index 7ed6a9a2be5bf45730266f04ab1c24ca4af6e077..d1d792a000c784f045d47a3a511df1d81dd3f871 100644 (file)
@@ -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);
 }
index dea4551378cadc7e2727e99e127ef7512f91f3db..ca4b58d5988d21befdb8bf6be135d7a4b9f7b782 100644 (file)
@@ -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" : (
index 19976f72684a7a6f692622262ffcea61fca14c86..9e6f24ee70ee4ec38dbf754305a0609f044f9871 100644 (file)
@@ -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;
 }
index 7ed6a9a2be5bf45730266f04ab1c24ca4af6e077..d1d792a000c784f045d47a3a511df1d81dd3f871 100644 (file)
@@ -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);
 }
index dea4551378cadc7e2727e99e127ef7512f91f3db..ca4b58d5988d21befdb8bf6be135d7a4b9f7b782 100644 (file)
@@ -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" : (