Files
Maksim Levental ead7fbd791 [mlir][python] Fix segfault at interpreter shutdown with entered contexts (#203826)
The `static thread_local std::vector<PyThreadContextEntry>` holds
`nb::object` references to Python Context/Location/InsertionPoint
objects. When a Context is entered (pushed onto the stack) but never
exited before interpreter shutdown, the thread-local storage destructor
runs after `Py_Finalize()` on the main thread, attempting `Py_DECREF`
through the dead runtime → SIGSEGV.

Fix: Register an `atexit` handler that clears the stack while the
interpreter is still alive, releasing all held Python references before
finalization.
2026-06-15 12:32:36 -07:00
..