fix #5381: the -debug RTS could crash with "internal error: MVAR_CLEAN
authorSimon Marlow <marlowsd@gmail.com>
Mon, 8 Aug 2011 08:12:08 +0000 (09:12 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 8 Aug 2011 12:48:39 +0000 (13:48 +0100)
on mutable list" after a call to tryPutMVar#.

I don't think this leads to any problems without -debug.

rts/PrimOps.cmm

index e17c6fb..bb4f73b 100644 (file)
@@ -1451,10 +1451,6 @@ stg_tryPutMVarzh
     info = GET_INFO(mvar);
 #endif
 
-    if (info == stg_MVAR_CLEAN_info) {
-        foreign "C" dirty_MVAR(BaseReg "ptr", mvar "ptr");
-    }
-
     if (StgMVar_value(mvar) != stg_END_TSO_QUEUE_closure) {
 #if defined(THREADED_RTS)
        unlockClosure(mvar, info);
@@ -1462,6 +1458,10 @@ stg_tryPutMVarzh
        RET_N(0);
     }
   
+    if (info == stg_MVAR_CLEAN_info) {
+        foreign "C" dirty_MVAR(BaseReg "ptr", mvar "ptr");
+    }
+
     q = StgMVar_head(mvar);
 loop:
     if (q == stg_END_TSO_QUEUE_closure) {