Random FreeCAD Crashes With PySideUic

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
Posts: 155
Joined: Sat May 15, 2010 3:59 am

Random FreeCAD Crashes With PySideUic

Postby cblt2l » Sun May 18, 2014 5:52 am

So I'm working on a 3D Printing Workbench and I am experiencing problems with freecad randomly crashing when loading the CuraEngine Slicer Tool. Its very intermittent. Sometimes you can run it 30 times in a row without crashing, sometimes only 2. I observed that over the course of adding more widgets to the form and increasing the complexity, the frequency of crashing increased. So my gut tells me that it has something to do with PySideUic.loadUiType.

Steps to reproduce:
1) Load 3d Printing workbench
2) Select 'CuraEngine Slicer Tool' for the plugin (second button)
3) Select 'Cancel'
4) Repeat steps 2 & 3 until freecad crashes. Could be 2 ~ 30 iterations.

When doing this with a 'release' build of freecad, the error message is always:

Code: Select all

*** Abort *** an exception was raised, but no catch was found.
	... The exception is:SIGSEGV 'segmentation violation' detected. Address 8
So I build freecad with debugging turned on and installed debugging symbols for python, libqt4 & libc6. I then followed the instructions here and here and then ran with gdb to get a backtrace.

One thing I noticed initially is that even though I'm following the same procedure every time to reproduce the problem, the backtraces always seem to be different leading up to the crash. I figure that the general sequence of events should be the same every time, but then I'm an amateur at this kind of thing, so this maybe normal.

I have 3 backtraces attached. Anyone have an idea whats going on? Its all Greek to me... :?

This is the build that I used for debugging, however the issue has existed at least since the pyside migration.
OS: Debian GNU/Linux 7.5 (wheezy)
Platform: 64-bit
Version: 0.14.3653 (Git)
Branch: master
Hash: 15523efed7ca0e3dfd5aacdd053f7cd30c9a11a4
Python version: 2.7.3
Qt version: 4.8.2
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0
Backtraces of freecad crash
(8.27 KiB) Downloaded 31 times
User avatar
Posts: 155
Joined: Sat May 15, 2010 3:59 am

Re: Random FreeCAD Crashes With PySideUic

Postby cblt2l » Mon May 19, 2014 4:58 am

From viewtopic.php?f=10&t=5890&start=60#p47114
wmayer wrote:Back to the crash of the gear panel. It appeared that I was right with my assumption that it's due to the duplicate symbols of Qt's QtUiTools module which is linked by FreeCAD and PySide. So, I have implemented an alternative way which does not use PySide's QtUiTools any more and now it loads fine.
Ok so if I'm understanding this right, your thread here describes the correct way to load the UI and works around the KDE bug from the second link. For the code generation approach to loading the UI form the method from your thread is:

Code: Select all

Which is how I'm doing it and it still crashes.
User avatar
Posts: 155
Joined: Sat May 15, 2010 3:59 am

Re: Random FreeCAD Crashes With PySideUic

Postby cblt2l » Wed May 21, 2014 2:42 am

FWIW, I switched from code generation over to the UiLoader approach and crashes seem to be gone. Here's an example:

Code: Select all

import FreeCAD, FreeCADGui, os
from PySide import QtCore, QtGui
from FreeCADGui import PySideUic as uic

# Test two different methods of loading Qt Designer forms
# http://forum.freecadweb.org/viewtopic.php?f=10&t=5374

class CodeGen:
	'''Create Dialog Using Code Generation Approach'''
	def __init__(self):
		self.homeDir = os.path.expanduser("~")
		form_class, base_class = uic.loadUiType(self.homeDir + "/.FreeCAD/Form.ui")
		self.formUi = form_class()
		self.form = base_class()

class UiLoader(QtGui.QMainWindow):
	'''Create Dialog Using Ui Loader Approach'''
	def __init__(self):
		self.homeDir = os.path.expanduser("~")
		self.form=FreeCADGui.PySideUic.loadUi(self.homeDir + "/.FreeCAD/Form.ui")

for x in range(0, 50):
#	For code generation approach
#	panel=CodeGen()

#	For Ui Loader Approach

#	Show & close the form in the task dialog 50 times