]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
VG_(oursignalhandler): when catching a fatal signal, don't longjmp
authorJulian Seward <jseward@acm.org>
Wed, 24 Apr 2002 21:39:11 +0000 (21:39 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 24 Apr 2002 21:39:11 +0000 (21:39 +0000)
back to the scheduler if the signal is already pending.  There's
something very suspicious about all this, though.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@142

coregrind/vg_scheduler.c
coregrind/vg_signals.c
vg_scheduler.c
vg_signals.c

index d95ebf75fec2902bd7fc2d61e8ac7e659443ef94..855f710ecde3b00a963ef4e499fbd78862948857 100644 (file)
@@ -457,7 +457,7 @@ void VG_(save_thread_state) ( ThreadId tid )
 static
 UInt run_thread_for_a_while ( ThreadId tid )
 {
-   UInt trc = 0;
+   volatile UInt trc = 0;
    vg_assert(is_valid_tid(tid));
    vg_assert(vg_threads[tid].status == VgTs_Runnable);
    vg_assert(VG_(bbs_to_go) > 0);
index 7fc3b0ba1a7f032353792438b26b77bb19313fb3..87d058af35ac50445166f017296a54c8bb00190c 100644 (file)
@@ -362,6 +362,7 @@ Bool VG_(deliver_signals) ( ThreadId tid )
 
 static void VG_(oursignalhandler) ( Int sigNo )
 {
+   Bool          needs_to_be_delivered;
    Int           dummy_local;
    vki_ksigset_t saved_procmask;
 
@@ -395,6 +396,8 @@ static void VG_(oursignalhandler) ( Int sigNo )
 
    VG_(block_all_host_signals)( &saved_procmask );
 
+   needs_to_be_delivered = False;
+
    if (VG_(sighandler)[sigNo] == NULL) {
       if (VG_(clo_trace_signals)) {
          VG_(add_to_msg)("unexpected!");
@@ -431,14 +434,16 @@ static void VG_(oursignalhandler) ( Int sigNo )
          VG_(add_to_msg)("queued" );
          VG_(end_msg)();
       }
+      needs_to_be_delivered = True;
    }
 
    /* We've finished messing with the queue, so re-enable host
       signals. */
    VG_(restore_host_signals)( &saved_procmask );
 
-   if (sigNo == VKI_SIGSEGV || sigNo == VKI_SIGBUS 
-       || sigNo == VKI_SIGFPE || sigNo == VKI_SIGILL) {
+   if (needs_to_be_delivered 
+       && (sigNo == VKI_SIGSEGV || sigNo == VKI_SIGBUS 
+           || sigNo == VKI_SIGFPE || sigNo == VKI_SIGILL)) {
       /* Can't continue; must longjmp back to the scheduler and thus
          enter the sighandler immediately. */
       VG_(longjmpd_on_signal) = sigNo;
index d95ebf75fec2902bd7fc2d61e8ac7e659443ef94..855f710ecde3b00a963ef4e499fbd78862948857 100644 (file)
@@ -457,7 +457,7 @@ void VG_(save_thread_state) ( ThreadId tid )
 static
 UInt run_thread_for_a_while ( ThreadId tid )
 {
-   UInt trc = 0;
+   volatile UInt trc = 0;
    vg_assert(is_valid_tid(tid));
    vg_assert(vg_threads[tid].status == VgTs_Runnable);
    vg_assert(VG_(bbs_to_go) > 0);
index 7fc3b0ba1a7f032353792438b26b77bb19313fb3..87d058af35ac50445166f017296a54c8bb00190c 100644 (file)
@@ -362,6 +362,7 @@ Bool VG_(deliver_signals) ( ThreadId tid )
 
 static void VG_(oursignalhandler) ( Int sigNo )
 {
+   Bool          needs_to_be_delivered;
    Int           dummy_local;
    vki_ksigset_t saved_procmask;
 
@@ -395,6 +396,8 @@ static void VG_(oursignalhandler) ( Int sigNo )
 
    VG_(block_all_host_signals)( &saved_procmask );
 
+   needs_to_be_delivered = False;
+
    if (VG_(sighandler)[sigNo] == NULL) {
       if (VG_(clo_trace_signals)) {
          VG_(add_to_msg)("unexpected!");
@@ -431,14 +434,16 @@ static void VG_(oursignalhandler) ( Int sigNo )
          VG_(add_to_msg)("queued" );
          VG_(end_msg)();
       }
+      needs_to_be_delivered = True;
    }
 
    /* We've finished messing with the queue, so re-enable host
       signals. */
    VG_(restore_host_signals)( &saved_procmask );
 
-   if (sigNo == VKI_SIGSEGV || sigNo == VKI_SIGBUS 
-       || sigNo == VKI_SIGFPE || sigNo == VKI_SIGILL) {
+   if (needs_to_be_delivered 
+       && (sigNo == VKI_SIGSEGV || sigNo == VKI_SIGBUS 
+           || sigNo == VKI_SIGFPE || sigNo == VKI_SIGILL)) {
       /* Can't continue; must longjmp back to the scheduler and thus
          enter the sighandler immediately. */
       VG_(longjmpd_on_signal) = sigNo;