[FFI] Use the correct function in DecRef #15999
Conversation
Lunderberg
left a comment
There was a problem hiding this comment.
Oh my, that's a good catch, thank you! This would effectively mean that any python exception thrown across the FFI border would never be garbage-collected, and that any local variables in its stack trace would be in memory until the program exits. This is primarily used to improve debugging in cases where the exception is causing the program to exit anyways, but there's no guarantee that that's the case.
f37c3e5 to
d9d837b
Compare
d9d837b to
b8d09a1
Compare
|
The fix in this PR exposes an actual problem of making C++ wrapper of a Python object. Running In addition, I think we should also consider the stopping order of runtime here. After the Python runtime shuts down, DecRef can no longer be called. @Lunderberg Since this goes far beyond my initial intention of fixing a typo, can you take this over and make proper fix? |
|
@yelite Certainly, and I have PR #16021 opened which includes both the typo fix and the GIL handling. It looks like it was an issue not with the underlying API usage, that the GIL wasn't explicitly acquired before using the python API. This wasn't an issue in single-threaded usage, because the GIL was held by the parent scope. It also didn't trigger an error previously, because the calls to Regarding stopping order, we should be set. The main concern would be the unspecified order of static destructors across compilation units, where both the CPython implementation and the |
Found this problem when investigating for #15996
cc @Lunderberg