Issue 15637: Segfault reading null VMA (works fine in python 2.x) (original) (raw)

I can reproduce, but it's not obvious to me what the test does or why it should succeed rather than fail.

For the record, here is the gdb traceback:

#0 0x00007ffff53c6dc8 in XQueryExtension () from /usr/lib64/libX11.so.6 #1 0x00007ffff53ba4d4 in XInitExtension () from /usr/lib64/libX11.so.6 #2 0x00007ffff4959672 in XextAddDisplay () from /usr/lib64/libXext.so.6 #3 0x00007ffff4b5ea96 in ?? () from /usr/lib64/libXrandr.so.2 #4 0x00007ffff4b5ee36 in XRRQueryVersion () from /usr/lib64/libXrandr.so.2 #5 0x00007ffff59274ec in ffi_call_unix64 () at /home/antoine/cpython/default/Modules/_ctypes/libffi/src/x86/unix64.S:75 #6 0x00007ffff5926f5e in ffi_call (cif=0x7fffffffbd30, fn=0x7ffff4b5ee10 , rvalue= 0x7fffffffbe10, avalue=0x7fffffffbde0) at /home/antoine/cpython/default/Modules/_ctypes/libffi/src/x86/ffi64.c:492 #7 0x00007ffff590ed27 in _call_function_pointer (flags=4353, pProc=0x7ffff4b5ee10 , avalues=0x7fffffffbde0, atypes=0x7fffffffbdb0, restype=0x7ffff5b587e8, resmem=0x7fffffffbe10, argcount=3) at /home/antoine/cpython/default/Modules/_ctypes/callproc.c:800 #8 0x00007ffff590f90c in _ctypes_callproc (pProc=0x7ffff4b5ee10 , argtuple= (0, <CArgObject at remote 0x7ffff5b4c120>, <CArgObject at remote 0x7ffff5b4c350>), flags=4353, argtypes= 0x0, restype=<_ctypes.PyCSimpleType at remote 0xa171c0>, checker=0x0) at /home/antoine/cpython/default/Modules/_ctypes/callproc.c:1143 #9 0x00007ffff5908dec in PyCFuncPtr_call (self=0x7ffff5b4de60, inargs= (0, <CArgObject at remote 0x7ffff5b4c120>, <CArgObject at remote 0x7ffff5b4c350>), kwds=0x0) at /home/antoine/cpython/default/Modules/_ctypes/_ctypes.c:3804 #10 0x0000000000593e7b in PyObject_Call (func= <_FuncPtr(__name__='XRRQueryVersion') at remote 0x7ffff5b4de60>, arg= (0, <CArgObject at remote 0x7ffff5b4c120>, <CArgObject at remote 0x7ffff5b4c350>), kw=0x0) at Objects/abstract.c:2083 [...]

The example script has two errors IMO:

I strongly suggest to set .argtypes and .restype, to ensure proper type check and conversion.