Segfault in App::DocumentP::partialTopologicalSort

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Premik
Posts: 10
Joined: Sat Aug 19, 2017 9:50 am

Segfault in App::DocumentP::partialTopologicalSort

Post by Premik »

  • Open the attached Crash.fcstd.
  • Delete any of the three sketches. For example "Sketch004".
=> Segfault.
Note I already deleted some objects to narrow the problem down. So there are few exclamation marks..
Should I open a bug in Mantis?
OS: "Arch Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12960 (Git)
Build type: Debug
Branch: master
Hash: b6304d16a77f65f94aa5ec79f69688be61a42961
Python version: 2.7.14
Qt version: 5.10.0
Coin version: 3.1.3
OCC version: 6.9.1.oce-0.18
Locale: English/UnitedStates (en_US)
Thread 1 "FreeCAD" received signal SIGSEGV, Segmentation fault.
std::vector<App::DocumentObject*, std::allocator<App::DocumentObject*> >::_M_range_insert<std::_List_iterator<App::DocumentObject*> > (this=this@entry=0x7fffffffbd40, __position=0x7fffdc00d160,
__first=<error reading variable: Cannot access memory at address 0x55545800d040>, __last=__last@entry=0x12) at /usr/include/c++/7.2.1/bits/vector.tcc:636
636 const size_type __n = std::distance(__first, __last);
(gdb) bt
#0 std::vector<App::DocumentObject*, std::allocator<App::DocumentObject*> >::_M_range_insert<std::_List_iterator<App::DocumentObject*> > (this=this@entry=0x7fffffffbd40, __position=0x7fffdc00d160,
__first=<error reading variable: Cannot access memory at address 0x55545800d040>, __last=__last@entry=0x12) at /usr/include/c++/7.2.1/bits/vector.tcc:636
#1 0x00007ffff6c4144c in std::vector<App::DocumentObject*, std::allocator<App::DocumentObject*> >::_M_insert_dispatch<std::_List_iterator<App::DocumentObject*> > (__last=..., __first=..., __pos=..., this=0x7fffffffbd40) at /usr/include/c++/7.2.1/bits/stl_vector.h:1406
#2 std::vector<App::DocumentObject*, std::allocator<App::DocumentObject*> >::insert<std::_List_iterator<App::DocumentObject*>, void> (__last=0x12, __first=..., __position=..., this=0x7fffffffbd40) at /usr/include/c++/7.2.1/bits/stl_vector.h:1132
#3 App::DocumentP::partialTopologicalSort (this=<optimized out>, objects=std::vector of length 19, capacity 32 = {...}) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/App/Document.cpp:2352
#4 0x00007ffff6c418f9 in App::Document::recompute (this=0x5555579ab910) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/App/Document.cpp:2220
#5 0x00007ffff6c9c395 in App::DocumentPy::recompute (this=this@entry=0x555557723370, args=<optimized out>) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/App/DocumentPyImp.cpp:408
#6 0x00007ffff6c9c518 in App::DocumentPy::staticCallback_recompute (self=0x555557723378, args=<optimized out>) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/App/DocumentPy.cpp:1718
#7 0x00007ffff645f449 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#8 0x00007ffff64be886 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#9 0x00007ffff64d405a in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#10 0x00007ffff64db7f1 in run_mod () from /usr/lib/libpython2.7.so.1.0
#11 0x00007ffff64dd588 in PyRun_StringFlags () from /usr/lib/libpython2.7.so.1.0
#12 0x00007ffff687166a in Base::InterpreterSingleton::runString[abi:cxx11](char const*) (this=<optimized out>, sCmd=0x5555581a49c8 "App.getDocument(\"Crash\").recompute()") at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Base/Interpreter.cpp:232
#13 0x00007ffff7374c2a in Gui::Command::doCommand (eType=eType@entry=Gui::Command::Doc, sCmd=sCmd@entry=0x7ffff7a1d8d0 "App.getDocument(\"%s\").recompute()") at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/Command.cpp:475
#14 0x00007ffff7384725 in StdCmdDelete::activated (this=<optimized out>, iMsg=<optimized out>) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/CommandDoc.cpp:1159
#15 0x00007ffff737948b in Gui::Command::invoke (this=0x555555a278e0, i=0) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/Command.cpp:300
#16 0x00007ffff56e5a06 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/libQt5Core.so.5
#17 0x00007ffff5c6a383 in QAction::triggered(bool) () from /usr/lib/libQt5Widgets.so.5
#18 0x00007ffff5c6cc06 in QAction::activate(QAction::ActionEvent) () from /usr/lib/libQt5Widgets.so.5
#19 0x00007ffff5c6d5b6 in QAction::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
#20 0x00007ffff5c70e3c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#21 0x00007ffff5c78816 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#22 0x00007ffff7347ed9 in Gui::GUIApplication::notify (this=0x7fffffffd040, receiver=0x555557549220, event=0x7fffffffca20) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/GuiApplication.cpp:91
#23 0x00007ffff56b51e0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#24 0x00007fffef7fcdb9 in QShortcutMap::dispatchEvent(QKeyEvent*) () from /usr/lib/libQt5Gui.so.5
#25 0x00007fffef7fce8e in QShortcutMap::tryShortcut(QKeyEvent*) () from /usr/lib/libQt5Gui.so.5
#26 0x00007fffef7aa77d in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) () from /usr/lib/libQt5Gui.so.5
#27 0x00007fffef7c9f18 in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () from /usr/lib/libQt5Gui.so.5
#28 0x00007fffef7cf166 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib/libQt5Gui.so.5
#29 0x00007fffef7a6bbc in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Gui.so.5
#30 0x00007fffe4fd428d in ?? () from /usr/lib/libQt5XcbQpa.so.5
#31 0x00007ffff56b382b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#32 0x00007ffff56bcb18 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#33 0x00007ffff72f99fa in Gui::Application::runApplication () at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/Application.cpp:1902
#34 0x000055555555722c in main (argc=<optimized out>, argv=<optimized out>) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Main/MainGui.cpp:261
Attachments
Crash.fcstd
(7.32 KiB) Downloaded 50 times
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Segfault in App::DocumentP::partialTopologicalSort

Post by wmayer »

I can confirm the crash. But no need to report it as it's related to issue #0003214. The problem is that when deleting an object the expression still references the deleted object.

The partialTopologicalSort method only crashes because of the invalid document structure. If the above bug is fixed this crash will be fixed, too. But nevertheless one can verify the iterators in partialTopologicalSort to be on the safe side.
Premik
Posts: 10
Joined: Sat Aug 19, 2017 9:50 am

Re: Segfault in App::DocumentP::partialTopologicalSort

Post by Premik »

Thanks. I should have checked the reported bugs first.
Eitherway I can see it is already fixed in the tip.
OS: "Arch Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12960 (Git)
Build type: Debug
Branch: master
Hash: b6304d16a77f65f94aa5ec79f69688be61a42961
Python version: 2.7.14
Qt version: 5.10.0
Coin version: 3.1.3
OCC version: 6.9.1.oce-0.18
Locale: English/UnitedStates (en_US)
Post Reply