Problems when debugging Cython code

85 views
Skip to first unread message

juan...@gmail.com

unread,
Dec 14, 2017, 12:12:35 PM12/14/17
to cython-users
Hi all,

I have never used Cython but had the need to debug some Cython extensions, so after a bit of struggle I managed to create a debugging environment in Docker:

https://github.com/Juanlu001/cython-rasterio-debugging/

However, I'm seeing strange lookup errors when trying to print Python objects, or put Python breakpoints:

(gdb) cy break -p rasterio.open
Breakpoint 1 at 0x16022e: file ../Python/ceval.c, line 690.
(gdb) run
Starting program: /usr/bin/python2.7-dbg
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Python Exception <type 'exceptions.AttributeError'> 'Frame' object has no attribute 'is_evalframeex':
Error in testing breakpoint condition:
Error occurred in Python convenience function: 'Frame' object has no attribute 'is_evalframeex'

Breakpoint 1, PyEval_EvalFrameEx (f=Frame 0x7ffff7f35060, for file /usr/lib/python2.7/site.py, line 65, in <module> (), throwflag=0) at ../Python/ceval.c:690
690    ../Python/ceval.c: No such file or directory.


[...]

(gdb)
3891      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 32, __pyx_L1_error)
32        filename = filename.encode('utf-8')
(gdb) cy print filename
Python Exception <type 'exceptions.AttributeError'> 'PyDictObjectPtr' object has no attribute 'items':
Error occurred in Python command: 'PyDictObjectPtr' object has no attribute 'items'


Still, printing C/Cython objects with plain GDB commands just works:

(gdb)
3893      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 32, __pyx_L1_error)
3895      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3896      __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_2);
3897      __pyx_t_2 = 0;
3906      __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(1, 33, __pyx_L1_error)
33        fname = filename
(gdb)
3907      __pyx_v_fname = __pyx_t_3;
3916      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_allowed_drivers); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 37, __pyx_L1_error)
37        if allowed_drivers:
(gdb) p __pyx_t_3
$1 = 0x7ffff7fb0b1c "raster.tif"


Could somebody tell me if I'm doing something wrong here?

Hygor

unread,
Oct 6, 2018, 4:53:55 PM10/6/18
to cython-users
Hi, did you solve this problem?

(gdb) cy print some_variable
Python Exception <type 'exceptions.AttributeError'> 'PyDictObjectPtr' object has no attribute 'items':
Error occurred in Python: 'PyDictObjectPtr' object has no attribute 'items'


I'm also getting this one sometimes (usually after the first one):

Python Exception <class 'gdb.error'> There is no member named ob_sval.:
Error occurred in Python command: There is no member named ob_sval.


Stefan Behnel

unread,
Oct 14, 2018, 6:25:06 AM10/14/18
to cython...@googlegroups.com
Hygor schrieb am 04.10.2018 um 22:08:
> (gdb) cy print some_variable
> Python Exception <type 'exceptions.AttributeError'> 'PyDictObjectPtr' object
> has no attribute 'items':
> Error occurred in Python: 'PyDictObjectPtr' object has no attribute 'items'

Might be related to the new dict implementation in Py3.6+. Someone needs to
check if the gdb support in CPython has been updated accordingly, and if
yes, apply the same change to "libpython.py" in Cython.

Could you please open a ticket in the github bug tracker? Maybe you can
also investigate the above in CPython?

Stefan

Hygor

unread,
Nov 2, 2018, 12:14:52 PM11/2/18
to cython-users
Hi Stefan, thanks for replying. I created an issue on github as requested https://github.com/cython/cython/issues/2699.
I don't know if it is related to Py3 as I was only using Py2 in my code.
From what I read here https://devguide.python.org/gdb/ the gdb support does seems to be updated, but I might be wrong.
Reply all
Reply to author
Forward
0 new messages