Using borrowed object after destroying context causes segfault.
Opened this issue · 0 comments
vickenty commented
Demo.
While this is clearly a bug in the user code and current behaviour is not worse than that of the C library, a Python module can probably do better than crash the interpreter.
One way to fix this would be to add a Context reference to all Objects to ensure that context lives long enough. Another - to add a weak reference instead, so objects would be able to check if context is alive before making library calls and handle released context gracefully.
Personally, I think that the weakref approach would be better as it is more consistent with the style of the C API, even if it has slightly more overhead. What do you think?