Repository navigation
hal: hold the query enum types as py::handle - #4853
Merged
Merged
Conversation
LinuxCNC aborts on exit on Fedora 45, and so does python3 -c 'import hal' (issue LinuxCNC#4849). halquery.cc kept the _hal Type, Dir and CompType enums in static py::object variables. The extra inc_ref() stopped the enums from being freed, but the static destructors still ran dec_ref() at process exit, after the interpreter had finalized. pybind11 3.x checks that the GIL is held in dec_ref() and terminates. Store them as py::handle, which has no destructor, and keep the reference with release(). Nothing runs at exit any more: the object file registers no exit-time destructors (three before). Fixes LinuxCNC#4849
Contributor
|
Can confirm, all is well now, thank you! |
NTULINUX
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4849.
halquery.cc kept the
_halType, Dir and CompType enums instatic py::objectvariables. Theinc_ref()stopped them from being freed, but the static destructors still randec_ref()at process exit, after the interpreter had finalized. pybind11 3.x checks the GIL there and aborts, so on Fedora 45 LinuxCNC andpython3 -c 'import hal'crash on exit.I hold them as
py::handle, which has no destructor, and keep the reference withrelease().halquery.o registers three exit-time destructors before and none after. tests/halmodule passes.
@NTULINUX, could you test this on Fedora 45?