Fix a couple of bugs in the throwTo handling, exposed by conc016(threaded2)
[ghc-hetmet.git] / rts / HeapStackCheck.cmm
index a528a3f..ba672bf 100644 (file)
@@ -631,8 +631,12 @@ INFO_TABLE_RET( stg_block_throwto, RET_SMALL, P_ unused, P_ unused )
 
 stg_block_throwto_finally
 {
-    // unlock the throwto message
-    unlockClosure(StgTSO_block_info(CurrentTSO), stg_MSG_THROWTO_info);
+    // unlock the throwto message, but only if it wasn't already
+    // unlocked.  It may have been unlocked if we revoked the message
+    // due to an exception being raised during threadPaused().
+    if (StgHeader_info(StgTSO_block_info(CurrentTSO)) == stg_WHITEHOLE_info) {
+        unlockClosure(StgTSO_block_info(CurrentTSO), stg_MSG_THROWTO_info);
+    }
     jump StgReturn;
 }