View Issue Details

IDProjectCategoryView StatusLast Update
0002919FreeCADBugpublic2017-02-25 04:13
Reporterblacey Assigned Toyorik  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
PlatformAppleOSMac OS XOS Version10.11.x
Product Version0.17 
Target Version0.17 
Summary0002919: FEM Workbench crashes during activation when using VTK 7.1 with Python bindings
DescriptionBuilding FreeCAD against VTK 7.1 with Python Bindings enables VTK access from Python within FreeCAD. In this configuration, I am able to create and even display a cylinder using VTK from FreeCAD's Python console however if I activate the FEM Workbench, a segmentation fault is raised. Below is the output from lldb.


Process 77669 stopped
* thread #1: tid = 0xda09ab, 0x00000001000deebe libFreeCADGui.dylib`Gui::Application::sActivateWorkbenchHandler((null)=0x0000000000000000, args=0x0000000107dbb590, (null)=0x0000000000000000) + 46 at ApplicationPy.cpp:685, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
    frame #0: 0x00000001000deebe libFreeCADGui.dylib`Gui::Application::sActivateWorkbenchHandler((null)=0x0000000000000000, args=0x0000000107dbb590, (null)=0x0000000000000000) + 46 at ApplicationPy.cpp:685
   682 	PyObject* Application::sActivateWorkbenchHandler(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
   683 	{
   684 	    char*       psKey;
-> 685 	    if (!PyArg_ParseTuple(args, "s", &psKey))     // convert args: Python->C 
* thread #1: tid = 0xda09ab, 0x0000000135ccd4da Python`___lldb_unnamed_symbol976$$Python + 127, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
    frame #0: 0x0000000135ccd4da Python`___lldb_unnamed_symbol976$$Python + 127
Python`___lldb_unnamed_symbol976$$Python:
->  0x135ccd4da <+127>: movl   0x18(%rax), %ecx
    0x135ccd4dd <+130>: incl   %ecx
    0x135ccd4df <+132>: movl   %ecx, 0x18(%rax)
    0x135ccd4e2 <+135>: leaq   0xca593(%rip), %rax       ; _Py_CheckRecursionLimit


OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9784 (Git)
Build type: DEBUG
Branch: master
Hash: febb6bf810d8f77903481a7c9d825e7ad906e9ea
Python version: 2.7.13
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Steps To Reproduce1. Build and install VTK 7.1 WITH Python Bindings
2. Build FreeCAD (febb6b)
3. Launch FreeCAD
4. Activate the FEM Workbench
Additional InformationBacktrace for crash


(lldb) bt
* thread #1: tid = 0xda09ab, 0x0000000135ccd4da Python`___lldb_unnamed_symbol976$$Python + 127, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x0000000135ccd4da Python`___lldb_unnamed_symbol976$$Python + 127
    frame #1: 0x0000000101d1c54c Python`PyObject_Repr + 59
    frame 0000002: 0x0000000101a1a7a7 libFreeCADBase.dylib`Py::Object::repr(this=0x00007fff5fbf6290) const + 39 at cxxsupport.cxx:55
    frame 0000003: 0x0000000101a07a6b libFreeCADBase.dylib`Py::Object::validate(this=0x00007fff5fbf6290) + 379 at cxx_extensions.cxx:109
    frame 0000004: 0x00000001322f7563 Fem.so`Py::Object::set(this=0x00007fff5fbf6290, pyob=0x000000013b154050, owned=true) + 83 at Objects.hxx:167
    frame 0000005: 0x00000001323ae15d Fem.so`Py::Tuple::Tuple(this=0x00007fff5fbf6290, size=2) + 93 at Objects.hxx:2310
    frame 0000006: 0x00000001323adf8d Fem.so`Py::Tuple::Tuple(this=0x00007fff5fbf6290, size=2) + 29 at Objects.hxx:2309
    frame 0000007: 0x00000001323aaca9 Fem.so`Py::ExtensionModule<Fem::Module>::initialize(this=0x000000012e9659a0, module_doc="This module is the Fem module.") + 1161 at ExtensionModule.hxx:138
    frame 0000008: 0x00000001323a6eaf Fem.so`Fem::Module::Module(this=0x000000012e9659a0) + 447 at AppFemPy.cpp:108
    frame 0000009: 0x00000001323a6cc5 Fem.so`Fem::Module::Module(this=0x000000012e9659a0) + 21 at AppFemPy.cpp:84
    frame 0000010: 0x00000001323a6c3a Fem.so`Fem::initModule() + 42 at AppFemPy.cpp:322
    frame 0000011: 0x00000001323a67eb Fem.so`::initFem() + 171 at AppFem.cpp:88
    frame 0000012: 0x0000000101d81a86 Python`_PyImport_LoadDynamicModule + 140
    frame 0000013: 0x0000000101d80782 Python`import_submodule + 267
    frame 0000014: 0x0000000101d80348 Python`load_next + 280
    frame 0000015: 0x0000000101d7f50f Python`PyImport_ImportModuleLevel + 1133
    frame 0000016: 0x0000000101d6133e Python`builtin___import__ + 135
    frame 0000017: 0x0000000101cec921 Python`PyObject_Call + 99
    frame 0000018: 0x0000000101d6fe37 Python`PyEval_CallObjectWithKeywords + 165
    frame 0000019: 0x0000000101d6b051 Python`PyEval_EvalFrameEx + 20765
    frame 0000020: 0x0000000101d65d3e Python`PyEval_EvalCodeEx + 1617
    frame 0000021: 0x0000000101d0ac73 Python`function_call + 350
    frame 0000022: 0x0000000101cec921 Python`PyObject_Call + 99
    frame 0000023: 0x0000000101cf7685 Python`instancemethod_call + 173
    frame 0000024: 0x0000000101cec921 Python`PyObject_Call + 99
    frame 0000025: 0x0000000101d6fe37 Python`PyEval_CallObjectWithKeywords + 165
    frame 0000026: 0x00000001000bac73 libFreeCADGui.dylib`Py::Callable::apply(this=0x00007fff5fbf7498, args=0x00007fff5fbf7568) const + 67 at Objects.hxx:3227
    frame 0000027: 0x00000001000b8ed7 libFreeCADGui.dylib`Gui::Application::activateWorkbench(this=0x00007fff5fbfc480, name="FemWorkbench") + 4583 at Application.cpp:967
    frame 0000028: 0x00000001000def69 libFreeCADGui.dylib`Gui::Application::sActivateWorkbenchHandler((null)=0x0000000000000000, args=0x0000000107dbb590, (null)=0x0000000000000000) + 217 at ApplicationPy.cpp:696
    frame 0000029: 0x0000000101d6c86a Python`PyEval_EvalFrameEx + 26934
    frame 0000030: 0x0000000101d65d3e Python`PyEval_EvalCodeEx + 1617
    frame 0000031: 0x0000000101d656e7 Python`PyEval_EvalCode + 48
    frame 0000032: 0x0000000101d89068 Python`run_mod + 53
    frame 0000033: 0x0000000101d89225 Python`PyRun_StringFlags + 109
    frame 0000034: 0x0000000101a699ac libFreeCADBase.dylib`Base::InterpreterSingleton::runString(this=0x0000000105d10120, sCmd="Gui.activateWorkbench(\"FemWorkbench\")") + 412 at Interpreter.cpp:196
    frame 0000035: 0x00000001001b0560 libFreeCADGui.dylib`Gui::Command::doCommand(eType=Gui, sCmd="Gui.activateWorkbench(\"%s\")") + 720 at Command.cpp:475
    frame 0000036: 0x00000001001e0068 libFreeCADGui.dylib`StdCmdWorkbench::activated(this=0x0000000114811510, i=4) + 2264 at CommandStd.cpp:99
    frame 0000037: 0x00000001001af9f4 libFreeCADGui.dylib`Gui::Command::invoke(this=0x0000000114811510, i=4) + 132 at Command.cpp:300
    frame 0000038: 0x00000001001a39e4 libFreeCADGui.dylib`Gui::ActionGroup::onActivated(this=0x000000010e794570, a=0x000000010e7519e0) + 628 at Action.cpp:350
    frame #39: 0x00000001001aa11d libFreeCADGui.dylib`Gui::ActionGroup::qt_static_metacall(_o=0x000000010e794570, _c=InvokeMetaMethod, _id=2, _a=0x00007fff5fbf91a0) + 221 at moc_Action.cpp:128
    frame #40: 0x00000001055b41fb QtCore`QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 2077
    frame 0000041: 0x00000001047f95d8 QtGui`QActionGroupPrivate::_q_actionTriggered() + 108
    frame 0000042: 0x00000001055b41fb QtCore`QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 2077
    frame 0000043: 0x00000001047f85e2 QtGui`QAction::activate(QAction::ActionEvent) + 208
    frame 0000044: 0x00000001001a48b7 libFreeCADGui.dylib`QAction::trigger(this=0x000000010e7519e0) + 23 at qaction.h:218
    frame 0000045: 0x00000001001a634d libFreeCADGui.dylib`Gui::WorkbenchGroup::customEvent(this=0x000000010e794570, e=0x00000001259f5990) + 61 at Action.cpp:581
    frame 0000046: 0x00000001055b01b9 QtCore`QObject::event(QEvent*) + 705
    frame 0000047: 0x00000001048001ac QtGui`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 194
    frame 0000048: 0x0000000104802c8c QtGui`QApplication::notify(QObject*, QEvent*) + 6474
    frame 0000049: 0x00000001001711a6 libFreeCADGui.dylib`Gui::GUIApplication::notify(this=0x00007fff5fbfc970, receiver=0x000000010e794570, event=0x00000001259f5990) + 934 at GuiApplication.cpp:91
    frame 0000050: 0x000000010559faf0 QtCore`QCoreApplication::notifyInternal(QObject*, QEvent*) + 118
    frame 0000051: 0x00000001055a0574 QtCore`QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 622
    frame 0000052: 0x00007fff760ca3c1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame 0000053: 0x00007fff760ab2cd CoreFoundation`__CFRunLoopDoSources0 + 557
    frame 0000054: 0x00007fff760aa7c6 CoreFoundation`__CFRunLoopRun + 934
    frame 0000055: 0x00007fff760aa1c4 CoreFoundation`CFRunLoopRunSpecific + 420
    frame 0000056: 0x00007fff7561a51c HIToolbox`RunCurrentEventLoopInMode + 240
    frame 0000057: 0x00007fff7561a259 HIToolbox`ReceiveNextEventCommon + 184
    frame 0000058: 0x00007fff7561a186 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
    frame 0000059: 0x00007fff73bb45f4 AppKit`_DPSNextEvent + 1120
    frame 0000060: 0x00007fff7432fc3a AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
    frame 0000061: 0x00007fff73ba8f7b AppKit`-[NSApplication run] + 926
    frame 0000062: 0x00000001047bd11b QtGui`QEventDispatcherMac::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1725
    frame 0000063: 0x000000010559cfc5 QtCore`QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 77
    frame 0000064: 0x000000010559d13f QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 365
    frame 0000065: 0x000000010559ff4a QtCore`QCoreApplication::exec() + 200
    frame 0000066: 0x00000001000c6477 libFreeCADGui.dylib`Gui::Application::runApplication() + 25031 at Application.cpp:1743
    frame 0000067: 0x000000010000add6 FreeCAD`main(argc=1, argv=0x00007fff5fbff9c8) + 13030 at MainGui.cpp:238
    frame 0000068: 0x00007fff8ba12235 libdyld.dylib`start + 1
    frame 0000069: 0x00007fff8ba12235 libdyld.dylib`start + 1
Tagscrash, FEM, macOS, Start Workbench
FreeCAD Information

Activities

ian.rees

2017-02-23 18:06

developer   ~0008410

I can reproduce this on my machine. The crash happens when PyCXX starts initialising the FEM module, on the very first call to Tuple(2) there's a segfault. So, I think that means the FEM Python instance (sorry, don't have source in front of me ATM) is already in a bad state. Haven't managed to fix it yet, but I'm suspecting that our Python interpreter is getting in to a bad state due to one of:

  * Linking with VTK is overriding some part of our normal Python.
  * Some sort of GIL-related issue if VTK is also trying to run an interpreter?

Or, possibly it's just coincident with VTK, not sure. Will try to look at this more this evening.

ian.rees

2017-02-23 23:25

developer   ~0008416

Confirmed that the crash happens when VTK is built with Python bindings, but doesn't happen when it's not.

blacey

2017-02-24 16:45

developer   ~0008420

Ian, good news! I had it on my list to make a small change in CMakeLists.txt for parity with Linux (was on my list for a couple weeks) that I THOUGHT was benign. Apparently not, because it is sort of a fluke but it resolves the segmentation fault. Need to do a bit more testing but so far, it looks good.

Here is the PR: https://github.com/FreeCAD/FreeCAD/pull/554

ian.rees

2017-02-24 20:17

developer   ~0008425

Yep, that fixes it for me too. I found last night that several libraries were getting dynamically loaded when the FEM workbench was opened, including the system Python, so this fix makes sense.

yorik

2017-02-25 04:13

administrator   ~0008429

Fix committed to master branch.

Related Changesets

FreeCAD: master 9d4f8fad

2017-02-24 16:39:40

blacey


Committer: yorik Details Diff
Enable all VTK components available on macOS

Fixes 0002919
Affected Issues
0002919
mod - CMakeLists.txt Diff File

Issue History

Date Modified Username Field Change
2017-02-22 21:51 blacey New Issue
2017-02-22 21:51 blacey Status new => assigned
2017-02-22 21:51 blacey Assigned To => ian.rees
2017-02-22 21:51 blacey Tag Attached: crash
2017-02-22 21:51 blacey Tag Attached: FEM
2017-02-22 21:51 blacey Tag Attached: MacOSX
2017-02-22 21:51 blacey Tag Attached: Start Workbench
2017-02-22 21:53 blacey Description Updated
2017-02-22 21:53 blacey Steps to Reproduce Updated
2017-02-23 18:06 ian.rees Status assigned => confirmed
2017-02-23 18:06 ian.rees Note Added: 0008410
2017-02-23 23:25 ian.rees Note Added: 0008416
2017-02-24 16:45 blacey Note Added: 0008420
2017-02-24 20:17 ian.rees Status confirmed => closed
2017-02-24 20:17 ian.rees Resolution open => fixed
2017-02-24 20:17 ian.rees Note Added: 0008425
2017-02-25 04:13 yorik Changeset attached => FreeCAD master 9d4f8fad
2017-02-25 04:13 yorik Note Added: 0008429
2017-02-25 04:13 yorik Assigned To ian.rees => yorik
2020-11-13 14:08 Kunda1 Tag Renamed MacOSX => macOS