Skip to content

Draft: compiler: Rework handling of mutator aborting

Ben Gamari requested to merge wip/T22038 into master

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.

Merge request reports