summaryrefslogtreecommitdiff
path: root/rts/Schedule.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-08-18 12:48:27 -0400
committerBen Gamari <ben@smart-cactus.org>2022-08-19 19:10:26 -0400
commitc895c44911ec44b9506cbe97555753ac402d6acf (patch)
tree453c8d8346707d5c27d424a7fbf0bb6971ca1e89 /rts/Schedule.c
parente293029db0d60852908feaf2312794849194b08c (diff)
downloadhaskell-wip/T22038.tar.gz
compiler: Rework handling of mutator abortingwip/T22038
Previously `-dtag-inference-checks`, `-dcheck-prim-bounds`, and `-falignment-sanitization` all aborted by calling `barf` from the mutator. However, this can lead to deadlocks in the threaded RTS. For instance, in the case of `-dcheck-prim-bounds` the following can happen 1. the mutator takes a capability and begins execution 2. the bounds check fails, calling `barf` 3. `barf` calls `rtsFatalInternalErrorFn`, which in turn calls `endEventLogging` 4. `endEventLogging` calls `flushEventLog`, which it turn initiates a sync to request that all capabilities flush their local event logs 5. we deadlock as the the capability held by the crashing mutator can never join the sync To avoid this we now have a more principled means of aborting: we return to the scheduler setting the thread's return value to ThreadAborting. The scheduler will see this and call `barf`. Fixes #22038.
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r--rts/Schedule.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index bc0e7d3acf..ff74645392 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -571,8 +571,12 @@ run_thread:
ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task);
break;
+ case ThreadAborted:
+ interruptStgRts();
+ break;
+
default:
- barf("schedule: invalid thread return code %d", (int)ret);
+ barf("schedule: invalid thread return code %d", (int)ret);
}
if (ready_to_gc || scheduleNeedHeapProfile(ready_to_gc)) {
@@ -3090,7 +3094,7 @@ findRetryFrameHelper (Capability *cap, StgTSO *tso)
/* -----------------------------------------------------------------------------
findAtomicallyFrameHelper
- This function is called by stg_abort via catch_retry_frame primitive. It is
+ This function is called by stg_abort_tx via catch_retry_frame primitive. It is
like findRetryFrameHelper but it will only stop at ATOMICALLY_FRAME.
-------------------------------------------------------------------------- */