Runtime: a program's exit handler reaches no destroyed thread-local
exit destroys the exiting thread's thread-locals before it runs the exit handlers (macOS, the GNU C library), and LocalKey::with on a destroyed one panics, which in a handler aborts the process. The exits lane case an_exit_handler_s_common_calls_answer_as_on_any_thread aborted there on both: "cannot access a Thread Local Storage value during or after destruction" in calls_at_exit on the M3, and on lavapipe at warm::pass::warming from PipelineMemo::compute, in the handler's new_compute_pipeline_state. Every runtime thread-local whose type needs dropping that a program's call reaches is now read with try_with, with what the thread does once it can keep nothing: - the making budget's turn (pipeline/budget.rs): program_turn takes none there, holds_turn is false, and a turn's give-back and lend read the note with try_with; - the driver facts' expectation (driver_facts.rs): expecting runs the call alone, its messages relayed; - the creation log's split (pipeline/creation_log.rs): none noted; - the warm pass (warm/pass.rs): none; - a relayed compile's held sink messages (device/compiles.rs): the call alone, its messages delivered as raised; - a lowering's refusal (render/deferral.rs): lowering::refusing is false there, so a notice of a kind the device refuses while lowering is announced, as anywhere else; - the debug-build checks of kept resident uses (binding.rs) and of slot rebinds (the translator's bind/graphics.rs): skipped. dirty_pages, shards, resource_ids and contexts already read theirs with try_with; the rest hold Copy values with no destructor. docs/API.md's accepted differences under "Process exit" say what an exit handler's calls keep no state for.
This commit is contained in:
1 parent
8a339f1e21
commit
aba4034dca
11 files changed
+102
-38
No files matched your search
@@ -5313,6 +5313,12 @@ each item named states the rule in full.
|
||||
waits for those in progress, and leaves the rest of the runtime running, so the handler's other
|
||||
work is submitted and completes, as Metal's exit runs it. A making its work needs that had not
|
||||
begun answers the same.
|
||||
- **An exit handler's calls keep none of the runtime's state for their thread**: `exit` destroys
|
||||
the exiting thread's thread-locals before it runs the handlers (macOS, the GNU C library). There
|
||||
a pipeline's making takes no turn of the process's making budget, the driver's messages a making
|
||||
is measured to report reach the device's message sink rather than being withheld, and a notice
|
||||
of a kind the device's options refuse while lowering is announced, and refuses no call, where
|
||||
the handler's own thread lowers it.
|
||||
- **On a CPU device (lavapipe, SwiftShader), an exit handler the program registered before a
|
||||
later pipeline making finds the process exiting**: its waits answer `WaitWouldDeadlock` of
|
||||
`DeadlockCause::Exiting` and the work it commits stays pending, where Metal's exit runs it. A
|
||||
|
||||
Reference in new issue
Block a user