-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ctypes mishandles void
return type
#91353
Comments
On wasm targets, import ctypes
py = ctypes.pythonapi
freefunc = ctypes.CFUNCTYPE(None, ctypes.c_voidp)
RequestCodeExtraIndex = py._PyEval_RequestCodeExtraIndex
RequestCodeExtraIndex.argtypes = (freefunc,)
RequestCodeExtraIndex.restype = ctypes.c_ssize_t
SetExtra = py._PyCode_SetExtra
SetExtra.argtypes = (ctypes.py_object, ctypes.c_ssize_t, ctypes.c_voidp)
SetExtra.restype = ctypes.c_int
LAST_FREED = None
def myfree(ptr):
global LAST_FREED
LAST_FREED = ptr
FREE_FUNC = freefunc(myfree)
FREE_INDEX = RequestCodeExtraIndex(FREE_FUNC)
# Verify that the provided free function gets invoked
# when the code object is cleaned up.
f = eval('lambda:42')
SetExtra(f.__code__, FREE_INDEX, ctypes.c_voidp(100))
del f # crashes!! The problem: Due to a bug(?) ctypes can produce closures that have Closures code: checks if Direct call code: calls cpython/Modules/_ctypes/callproc.c Line 1212 in b183f48
|
I think that we can close this issue. Please feel free to reopen this issue if needed. |
Yeah, the issue is fixed in 3.11 and main branches. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: