Fix a race condition when PROFILING (#8453)
authorTakano Akio <aljee@hyper.cx>
Thu, 17 Oct 2013 13:50:43 +0000 (22:50 +0900)
committerAustin Seipp <austin@well-typed.com>
Sat, 2 Nov 2013 20:58:06 +0000 (15:58 -0500)
Signed-off-by: Austin Seipp <austin@well-typed.com>
rts/sm/Evac.c

index 223e2f3..577edc3 100644 (file)
@@ -955,9 +955,15 @@ selector_loop:
 #ifdef PROFILING
               // For the purposes of LDV profiling, we have destroyed
               // the original selector thunk, p.
-              SET_INFO((StgClosure*)p, (StgInfoTable *)info_ptr);
-              OVERWRITING_CLOSURE((StgClosure*)p);
-              SET_INFO((StgClosure*)p, &stg_WHITEHOLE_info);
+              if (era > 0) {
+                  // Only modify the info pointer when LDV profiling is
+                  // enabled.  Note that this is incompatible with parallel GC,
+                  // because it would allow other threads to start evaluating
+                  // the same selector thunk.
+                  SET_INFO((StgClosure*)p, (StgInfoTable *)info_ptr);
+                  OVERWRITING_CLOSURE((StgClosure*)p);
+                  SET_INFO((StgClosure*)p, &stg_WHITEHOLE_info);
+              }
 #endif
 
               // the closure in val is now the "value" of the