Segfault in the bowels of pyside2 and qt5

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
mlampert
Posts: 1279
Joined: Fri Sep 16, 2016 9:28 pm

Segfault in the bowels of pyside2 and qt5

Postby mlampert » Wed Apr 24, 2019 4:21 am

sliptonic challenged me to a little exercise, which is never a good sign, and the result is a segfault (see below). The interesting part is that the segfault seems to be deterministic, seen the same stack backtrace multiple times.

Producing it is rather simple, double click on a Path.Job object in the tree and once the editor shows up dismiss it by pressing OK - rinse and repeat. Along the way you might also see some other strange things - it looks like mapping between the gui file and python gets out of whack (frame widgets end up becoming list widgets, table headers are plain QWidgets ...) - not sure if that is a clue or a distraction for the segfault:

Code: Select all

Program received signal SIGSEGV, Segmentation fault.                                                      
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x37940) [0x7f33e6342940]                                            
#1  0x7f33e7572e36 in QLineEdit::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x26    
#2  /usr/lib/python3/dist-packages/PySide2/QtWidgets.cpython-37m-x86_64-linux-gnu.so(+0x425703) [0x7f33cec0a703]                                                                                                    
#3  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyMethodDef_RawFastCallKeywords+0x2e8) [0x7f33e8fe3d38]                                                                                                         
#4  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyMethodDescr_FastCallKeywords+0x4a) [0x7f33e8fe488a] 
#5  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x8b9c) [0x7f33e8de69bc]      
#6  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(+0x79493) [0x7f33e8de8493]                             
#7  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x8305) [0x7f33e8de6125]      
#8  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(+0x79493) [0x7f33e8de8493]                             
#9  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x8305) [0x7f33e8de6125]      
#10  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(+0x79493) [0x7f33e8de8493]                            
#11  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x8305) [0x7f33e8de6125]     
#12  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalCodeWithName+0x996) [0x7f33e8f0d456]      
#13  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyFunction_FastCallKeywords+0x93) [0x7f33e8fe41a3]   
#14  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x8305) [0x7f33e8de6125]     
#15  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalCodeWithName+0x996) [0x7f33e8f0d456]      
#16  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyFunction_FastCallKeywords+0x93) [0x7f33e8fe41a3]   
#17  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x8305) [0x7f33e8de6125]     
#18  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalCodeWithName+0x996) [0x7f33e8f0d456]      
#19  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyFunction_FastCallDict+0xae) [0x7f33e8fe438e]       
#20  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyObject_Call_Prepend+0xcd) [0x7f33e8fe728d]         
#21  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(PyObject_Call+0x75) [0x7f33e8fe4cf5]                  
#22  0x7f33ea9f196b in Py::Callable::apply(Py::Tuple const&) const from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x3b                                                                      
#23  0x7f33eae41e3e in Gui::ViewProviderPythonFeatureImp::setEdit(int) from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x4f4                                                                 
#24  0x7f33c603c141 in Gui::ViewProviderPythonFeatureT<PathGui::ViewProviderPath>::setEdit(int) from /media/sdb/projects/FreeCAD/mlampert/build/Mod/Path/PathGui.so+0x27                                            
#25  0x7f33eae1249f in Gui::ViewProvider::startEditing(int) from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x2d                                                                             
#26  0x7f33eadcc08f in Gui::View3DInventorViewer::setEditingViewProvider(Gui::ViewProvider*, int) from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x3f                                       
#27  0x7f33eaa59384 in Gui::Document::setEdit(Gui::ViewProvider*, int) from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x1d4                                                                 
#28  0x7f33eae32217 in Gui::ViewProviderDragger::doubleClicked() from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x35                                                                        
#29  0x7f33c603c247 in Gui::ViewProviderPythonFeatureT<PathGui::ViewProviderPath>::doubleClicked() from /media/sdb/projects/FreeCAD/mlampert/build/Mod/Path/PathGui.so+0x45                                         
#30  0x7f33eac53b7c in Gui::TreeWidget::mouseDoubleClickEvent(QMouseEvent*) from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x15a                                                            
#31  0x7f33e74780bf in QWidget::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0xd0f    
#32  0x7f33e751ad1e in QFrame::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1e      
#33  0x7f33e768c1bb in QAbstractItemView::viewportEvent(QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1ab                                                                                            
#34  0x7f33e76f440b in QTreeView::viewportEvent(QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x3b                                                                                                     
#35  0x7f33e6abe2bb in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x9b                                                                
#36  0x7f33e74394a1 in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x71                                                                                 
#37  0x7f33e7440b98 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x458                                                                                              
#38  0x7f33eaac1821 in Gui::GUIApplication::notify(QObject*, QEvent*) from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0xff                                                                   
#39  0x7f33e6abe5a9 in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x179                                                                                    
#40  0x7f33e743fec9 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1a9                 
#41  /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(+0x1b8014) [0x7f33e7492014]                             
#42  /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(+0x1bab9e) [0x7f33e7494b9e]                             
#43  0x7f33e74394b1 in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x81                                                                                 
#44  0x7f33e7440950 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x210                                                                                              
#45  0x7f33eaac1821 in Gui::GUIApplication::notify(QObject*, QEvent*) from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0xff                                                                   
#46  0x7f33e6abe5a9 in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x179                                                                                    
#47  0x7f33e6e69f7c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x69c                                                    
#48  0x7f33e6e6be25 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x135                                      
#49  0x7f33e6e4606b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5+0xab                                                     
#50  /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5(+0xdd3eb) [0x7f33e15203eb]                               
#51  0x7f33e6abd27b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x13b                                                                                 
#52  0x7f33e6ac5262 in QCoreApplication::exec() from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x92       
#53  0x7f33ea9ec610 in Gui::Application::runApplication() from /home/markus/projects/FreeCAD/mlampert/build/lib/libFreeCADGui.so+0x22b6                                                                             
#54  ../build/bin/FreeCAD(main+0xa74) [0x5576111e3073]                                                    
#55  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb) [0x7f33e632f09b]                             
#56  ../build/bin/FreeCAD(_start+0x2a) [0x5576111e24ca]                                                   
markus@yolanda:~/projects/FreeCAD/mlampert/FreeCAD$
Not sure where and how to start triaging this one - pointers? takers?