How to build PySide6 with debugging symbols?
-
In an attempt to understand the root cause of a segmentation fault that occurs in my program, I want to get some insight into its state at the time of the crash with
gdb
. To this end, I need a flavour of PySide6 that contains debug symbols for everything.I did not find pre-built packages that I can use "as is", so I try to build it by following these instructions, since they say "... build and install the project with debug symbols...", which sounds like what I need.
However, it fails:
error: option --qtpaths not recognized Traceback (most recent call last): File "/home/alex/arc/pyside-setup/setup.py", line 78, in <module> setup_runner.run_setup() File "/home/alex/arc/pyside-setup/build_scripts/setup_runner.py", line 167, in run_setup raise RuntimeError(msg) RuntimeError: setup.py invocation failed with exit code: 1. setup.py invocation was: /home/alex/arc/pyside-setup/qtenv/bin/python setup.py build --qtpaths=/usr/bin/qtpaths --build-tests --ignore-git --parallel=16 --internal-build-type=shiboken6
Additional context: at this stage I'd like to get a bit of general guidance, because I am not sure I understand the big picture. I assumed that I need to build Qt itself with debug symbols first, but the aforementioned guide promises that debug symbols will be included. I assume, again, that this refers to the C++ binaries, because Python code is readable as it is.
It is possible that I'm completely on the wrong track. If there are better ways to troubleshoot segmentation faults, I would greatly appreciate some tips.
In the past I could deal with segfaults while writing programs that started from a clean slate and grew in complexity, without getting out of the "Python world". However, in this case I have an existing application with a complex UI that includes many widgets - many things are happening all over the place, and so far I have been unable to narrow it down to a specific part of the logic.
The very top of the backtrace looks like this
#0 0x00007fffbc3e2366 in QGraphicsScene::clearSelection() () at /opt/devpy39dbg/lib/python3.9/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6 #1 0x00007fffbc3c6047 in QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent*) () at /opt/devpy39dbg/lib/python3.9/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6 #2 0x00007fffbc955090 in Sbk_QGraphicsItemFunc_mousePressEvent () at /opt/devpy39dbg/lib/python3.9/site-packages/PySide6/QtWidgets.abi3.so #3 0x00005555557979e7 in cfunction_vectorcall_O (func=<built-in method mousePressEvent of GRPoint object at remote 0x7ffee793b960>, args=0x7ffee50bf750, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:512 #4 0x000055555567e365 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=9223372036854775809, args=0x7ffee50bf750, callable=<built-in method mousePressEvent of GRPoint object at remote 0x7ffee793b960>, tstate=0x5555559ae8e0) at ./Include/cpython/abstract.h:118
So, I understand that this happens inside the mouse event handler of a custom graphics item of the class
GRPoint
. But there are thousands of them on the scene, so I cannot wrap my mind around this problem yet. -
If the option
--qtpaths
is not recognized, you might not be using the proper branch. Can you verify that? but in any case, as I can see from your option, that option is not needed, because qtpaths is already in your path (assumming it's really on/usr/bin/qtpaths
, you can check that aswhich qtpaths
)Usually the rule is:
- If you are hunting for a possible bug in Qt, you need Qt with debug symbols.
- If you are hunting for a possible bug in PySide, you need PySide with debug symbols, and not Qt.
Additionally, if you would like to get into the Python C implementation, you might need a Python interpreter with debug symbols.
In your case, having only PySide with debug symbols will be enough, then it's just a matter of using the same interpreter you used to build pyside and run
gdb --args /path/to/your/python your_code.py
and then just wait until it segfaults.From your stacktrace, it seems the issue starts with the PySide wrapper from the widgets, and that might unfold the issue with the data that you are calling the
QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent*)
function.