Skip to content
Snippets Groups Projects
Commit 38f2f627 authored by GHC GitLab CI's avatar GHC GitLab CI
Browse files

rts/Messages: Add missing write barrier in THROWTO message update

After a THROWTO message has been handle the message closure is
overwritten by a NULL message. We must ensure that the original
closure's pointers continue to be visible to the nonmoving GC.

(cherry picked from commit 6c2faf158fd26fc06b03c9bd11b6d2cf8e8db572)
parent ef241371
No related branches found
No related tags found
No related merge requests found
...@@ -100,7 +100,7 @@ loop: ...@@ -100,7 +100,7 @@ loop:
case THROWTO_SUCCESS: { case THROWTO_SUCCESS: {
// this message is done // this message is done
StgTSO *source = t->source; StgTSO *source = t->source;
doneWithMsgThrowTo(t); doneWithMsgThrowTo(cap, t);
tryWakeupThread(cap, source); tryWakeupThread(cap, source);
break; break;
} }
......
...@@ -23,8 +23,16 @@ void sendMessage (Capability *from_cap, Capability *to_cap, Message *msg); ...@@ -23,8 +23,16 @@ void sendMessage (Capability *from_cap, Capability *to_cap, Message *msg);
#include "SMPClosureOps.h" #include "SMPClosureOps.h"
INLINE_HEADER void INLINE_HEADER void
doneWithMsgThrowTo (MessageThrowTo *m) doneWithMsgThrowTo (Capability *cap, MessageThrowTo *m)
{ {
// The message better be locked
ASSERT(m->header.info == &stg_WHITEHOLE_info);
IF_NONMOVING_WRITE_BARRIER_ENABLED {
updateRemembSetPushClosure(cap, (StgClosure *) m->link);
updateRemembSetPushClosure(cap, (StgClosure *) m->source);
updateRemembSetPushClosure(cap, (StgClosure *) m->target);
updateRemembSetPushClosure(cap, (StgClosure *) m->exception);
}
OVERWRITING_CLOSURE((StgClosure*)m); OVERWRITING_CLOSURE((StgClosure*)m);
unlockClosure((StgClosure*)m, &stg_MSG_NULL_info); unlockClosure((StgClosure*)m, &stg_MSG_NULL_info);
LDV_RECORD_CREATE(m); LDV_RECORD_CREATE(m);
......
...@@ -336,7 +336,7 @@ check_target: ...@@ -336,7 +336,7 @@ check_target:
} }
// nobody else can wake up this TSO after we claim the message // nobody else can wake up this TSO after we claim the message
doneWithMsgThrowTo(m); doneWithMsgThrowTo(cap, m);
raiseAsync(cap, target, msg->exception, false, NULL); raiseAsync(cap, target, msg->exception, false, NULL);
return THROWTO_SUCCESS; return THROWTO_SUCCESS;
...@@ -577,7 +577,7 @@ maybePerformBlockedException (Capability *cap, StgTSO *tso) ...@@ -577,7 +577,7 @@ maybePerformBlockedException (Capability *cap, StgTSO *tso)
throwToSingleThreaded(cap, msg->target, msg->exception); throwToSingleThreaded(cap, msg->target, msg->exception);
source = msg->source; source = msg->source;
doneWithMsgThrowTo(msg); doneWithMsgThrowTo(cap, msg);
tryWakeupThread(cap, source); tryWakeupThread(cap, source);
return 1; return 1;
} }
...@@ -599,7 +599,7 @@ awakenBlockedExceptionQueue (Capability *cap, StgTSO *tso) ...@@ -599,7 +599,7 @@ awakenBlockedExceptionQueue (Capability *cap, StgTSO *tso)
i = lockClosure((StgClosure *)msg); i = lockClosure((StgClosure *)msg);
if (i != &stg_MSG_NULL_info) { if (i != &stg_MSG_NULL_info) {
source = msg->source; source = msg->source;
doneWithMsgThrowTo(msg); doneWithMsgThrowTo(cap, msg);
tryWakeupThread(cap, source); tryWakeupThread(cap, source);
} else { } else {
unlockClosure((StgClosure *)msg,i); unlockClosure((StgClosure *)msg,i);
...@@ -696,7 +696,7 @@ removeFromQueues(Capability *cap, StgTSO *tso) ...@@ -696,7 +696,7 @@ removeFromQueues(Capability *cap, StgTSO *tso)
// ASSERT(m->header.info == &stg_WHITEHOLE_info); // ASSERT(m->header.info == &stg_WHITEHOLE_info);
// unlock and revoke it at the same time // unlock and revoke it at the same time
doneWithMsgThrowTo(m); doneWithMsgThrowTo(cap, m);
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment