YuanchengJiang · GitHub

Bug report

Bug description:

import ctypes
# The specific bug is triggered by creating a POINTER type using a string 
# (which issues a DeprecationWarning) and then using it for argument conversion.
BadType = ctypes.POINTER("BugTrigger")
# Load standard library (Linux/POSIX specific, matches the crash environment)
libc = ctypes.CDLL(None)
# Use any standard function (e.g., getpid) to attach argtypes
func = libc.getpid
func.argtypes = (BadType,)
try:
    # Calling the function forces ctypes to run PyCPointerType_from_param_impl
    # on the argument, triggering the "Assertion `typeinfo->proto' failed".
    func(ctypes.byref(ctypes.c_int(0)))
except Exception:
    pass
python: ../Modules/_ctypes/_ctypes.c:1422: PyObject *PyCPointerType_from_param_impl(PyObject *, PyTypeObject *, PyObject *): Assertion `typeinfo->proto' failed.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗