From ce9d03fa27ce85072d8ac1426d5420a5c0c215ee Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 3 Jan 2006 12:56:10 +0000 Subject: [PATCH] [project @ 2006-01-03 12:56:10 by simonmar] two fixes for the case when a (synchronous) exception is propagated to the top of a thread's stack, i.e. it is unhandled. 1. store the exception in the right place (we were using the OFFSET_StgTSO_stack macro and not accounting for the TSO's header size) 2. put an stg_enter_info on the stack so that the GC can understand this thread's stack. --- ghc/rts/Exception.cmm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ghc/rts/Exception.cmm b/ghc/rts/Exception.cmm index dc6305c..9d8d9d6 100644 --- a/ghc/rts/Exception.cmm +++ b/ghc/rts/Exception.cmm @@ -378,10 +378,15 @@ retry_pop_stack: } if (frame_type == STOP_FRAME) { - /* We've stripped the entire stack, the thread is now dead. */ - Sp = CurrentTSO + OFFSET_StgTSO_stack - + WDS(StgTSO_stack_size(CurrentTSO)) - WDS(1); - Sp(0) = R1; /* save the exception */ + /* + * We've stripped the entire stack, the thread is now dead. + * We will leave the stack in a GC'able state, see the stg_stop_thread + * entry code in StgStartup.cmm. + */ + Sp = CurrentTSO + TSO_OFFSET_StgTSO_stack + + WDS(StgTSO_stack_size(CurrentTSO)) - WDS(2); + Sp(1) = R1; /* save the exception */ + Sp(0) = stg_enter_info; /* so that GC can traverse this stack */ StgTSO_what_next(CurrentTSO) = ThreadKilled::I16; SAVE_THREAD_STATE(); /* inline! */ -- 1.7.10.4