[Bug?] Recent FreeCAD crashes when opening a file with TechDraw page made with the same version

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

[Bug?] Recent FreeCAD crashes when opening a file with TechDraw page made with the same version

Post by aapo »

Hi!

Attached you'll find a drawing of a rather basic part that I made with TechDraw in FreeCAD 0.19.18640. However, if I open the FCStd file containing the drawing with FreeCAD 0.19.18640 or 0.19.18671, I'll get a hard crash with no error messages (FreeCAD just closes), apparently at that point when FreeCAD tries to load the TechDraw page. The weird thing is that I can open the file (and the TechDraw drawing inside it) with FreeCAD 0.19.18504 just fine, even though it was saved with a more recent version. In other words, the more recent FreeCAD 0.19.18640 dies when trying to open a file saved with itself, while the older versions are fine with the offending file!

TLDR: The included .FCStd file causes a hard crash on load for me for any recent FreeCAD version.

2019-Lid-Lift-Steel-Hook-pic01.png
2019-Lid-Lift-Steel-Hook-pic01.png (88.28 KiB) Viewed 551 times



OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18671 (Git)
Build type: Release
Branch: master
Hash: 5476ab4b61fed05d37aae3a01ecd2e62d6d54200
Python version: 3.6.7
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)


OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18640 (Git)
Build type: Release
Branch: master
Hash: 2251f53eb5af097cbb4b879af89575132660e541
Python version: 3.6.7
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)


OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18504 (Git)
Build type: Release
Branch: master
Hash: f66023a646db4b2502bb3637897443b3525ca3c7
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)



EDIT: With a Linux machine I get the following crash when opening the file with v 0.19.18676. It seems to be related to the CenterLine loading and recomputing, even though in this case all the CenterLines should be "alive".

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x3a100) [0x7f4d17643100]
#1  0x7f4ca634df3a in opencascade::handle<TopoDS_TShape>::IsNull() const from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0xc
#2  0x7f4ca6344e54 in TopoDS_Shape::IsNull() const from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x18
#3  0x7f4ca643cf12 in TechDraw::BaseGeom::findEndPoints() from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x3c
#4  0x7f4ca643d148 in TechDraw::BaseGeom::getStartPoint() from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x24
#5  0x7f4ca6457466 in TechDraw::CenterLine::calcEndPoints2Lines(TechDraw::DrawViewPart*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, int, double, double, double, double, bool) from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x27a
#6  0x7f4ca6455dd2 in TechDraw::CenterLine::scaledGeometry(TechDraw::DrawViewPart*) from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x2b0
#7  0x7f4ca63d7e76 in TechDraw::DrawViewPart::addCenterLinesToGeom() from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x76
#8  0x7f4ca642d67b in TechDraw::DrawViewDetail::execute() from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x1455
#9  0x7f4d19ce3d02 in App::DocumentObject::recompute() from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0xc2
#10  0x7f4d19c0a497 in App::Document::_recomputeFeature(App::DocumentObject*) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0x1b5
#11  0x7f4d19c0b288 in App::Document::recomputeFeature(App::DocumentObject*, bool) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0xf8
#12  0x7f4d19ce3e85 in App::DocumentObject::recomputeFeature(bool) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0x3f
#13  0x7f4ca63d85dd in TechDraw::DrawViewPart::onDocumentRestored() from /home/alankine/software/freecad-build/Mod/TechDraw/TechDraw.so+0x1d
#14  0x7f4d19c04198 in App::Document::afterRestore(std::vector<App::DocumentObject*, std::allocator<App::DocumentObject*> > const&, bool) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0x600
#15  0x7f4d19c03975 in App::Document::afterRestore(bool) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0x5d
#16  0x7f4d19eb6213 in App::Application::openDocuments(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*, bool) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0x6e7
#17  0x7f4d19eb5a87 in App::Application::openDocument(char const*, bool) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0xc5
#18  0x7f4d19ee6515 in App::Application::sOpenDocument(_object*, _object*, _object*) from /home/alankine/software/freecad-build/lib/libFreeCADApp.so+0xe3
#19  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyMethodDef_RawFastCallKeywords+0x2db) [0x7f4d18db532b]
#20  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyCFunction_FastCallKeywords+0x28) [0x7f4d18db5c78]
#21  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(+0x6e250) [0x7f4d18bc6250]
#22  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x68a2) [0x7f4d18bccc42]
#23  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(_PyEval_EvalCodeWithName+0x92d) [0x7f4d18cee61d]
#24  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(PyEval_EvalCodeEx+0x3e) [0x7f4d18ceda2e]
#25  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(PyEval_EvalCode+0x1b) [0x7f4d18cef07b]
#26  /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0(PyRun_StringFlags+0x8f) [0x7f4d18cbdeef]
#27  0x7f4d19219b7c in Base::InterpreterSingleton::runString[abi:cxx11](char const*) from /home/alankine/software/freecad-build/lib/libFreeCADBase.so+0xd8
#28  0x7f4d1b1332a8 in Gui::Command::_runCommand(char const*, int, Gui::Command::DoCmd_Type, char const*) from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0xca
#29  0x7f4d1b132f76 in Gui::Command::_doCommand(char const*, int, Gui::Command::DoCmd_Type, char const*, ...) from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0x112
#30  0x7f4d1afe0b27 in Gui::Application::open(char const*, char const*) from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0x257
#31  0x7f4d1b14813a in StdCmdOpen::activated(int) from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0x84a
#32  0x7f4d1b131ee7 in Gui::Command::invoke(int, Gui::Command::TriggerSource) from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0x313
#33  0x7f4d1b1245da in Gui::Action::onActivated() from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0x26
#34  /home/alankine/software/freecad-build/lib/libFreeCADGui.so(+0xf596c3) [0x7f4d1b1296c3]
#35  0x7f4d17c633c8 in QMetaObject::activate(QObject*, int, int, void**) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x7b8
#36  0x7f4d1862e812 in QAction::triggered(bool) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x42
#37  0x7f4d18630e52 in QAction::activate(QAction::ActionEvent) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x102
#38  /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(+0x2df522) [0x7f4d187b2522]
#39  /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(+0x2e6baa) [0x7f4d187b9baa]
#40  0x7f4d187babd2 in QMenu::mouseReleaseEvent(QMouseEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x272
#41  0x7f4d18676786 in QWidget::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x246
#42  0x7f4d187bd1b3 in QMenu::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x153
#43  0x7f4d18634c32 in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x82
#44  0x7f4d1863e3e3 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x583
#45  0x7f4d1b0f911d in Gui::GUIApplication::notify(QObject*, QEvent*) from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0xff
#46  0x7f4d17c38a92 in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x182
#47  0x7f4d1863d4f3 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1b3
#48  /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(+0x1bf9d4) [0x7f4d186929d4]
#49  /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(+0x1c1ed4) [0x7f4d18694ed4]
#50  0x7f4d18634c32 in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x82
#51  0x7f4d1863e190 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x330
#52  0x7f4d1b0f911d in Gui::GUIApplication::notify(QObject*, QEvent*) from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0xff
#53  0x7f4d17c38a92 in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x182
#54  0x7f4d18016a33 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x6c3
#55  0x7f4d1801828b in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x24b
#56  0x7f4d17ff2eeb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5+0xbb
#57  /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5(+0x71d0a) [0x7f4d11ef7d0a]
#58  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x27d) [0x7f4d15b53ead]
#59  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x50130) [0x7f4d15b54130]
#60  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2f) [0x7f4d15b541bf]
#61  0x7f4d17c8e7f1 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x61
#62  0x7f4d17c3771b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x12b
#63  0x7f4d17c3f1c2 in QCoreApplication::exec() from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x92
#64  0x7f4d1afe9e81 in Gui::Application::runApplication() from /home/alankine/software/freecad-build/lib/libFreeCADGui.so+0x23b1
#65  bin/FreeCAD(main+0xb1e) [0x55c76b8e9158]
#66  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb) [0x7f4d1762fbbb]
#67  bin/FreeCAD(_start+0x2a) [0x55c76b8e84ca]

OS: Debian GNU/Linux bullseye/sid (KDE//usr/share/xsessions/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18676 (Git)
Build type: Unknown
Branch: master
Hash: 0347a4b7a61ae3af46ec8f6aac256efdc5b4bcb8
Python version: 3.7.5rc1
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Attachments
2019-Lid-Lift-Steel-Hook.FCStd
(71.83 KiB) Downloaded 19 times
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Bug?] Recent FreeCAD crashes when opening a file with TechDraw page made with the same version

Post by wandererfan »

aapo wrote: Tue Nov 05, 2019 3:06 pm TLDR: The included .FCStd file causes a hard crash on load for me for any recent FreeCAD version.
CenterLines seem to be thoroughly broken. Stay away from them while I sort things out.

WeldingSymbol is having trouble with finding the Svg icons. They are visible to the file manager, but TD says they aren't there.

Repaired versions of your file attached - one with no centerlines, and one with no centerlines and no welding. They open here with freecad-daily.

The dimensions are messed up due to the removal of the centerlines.
Attachments
2LineCLTest_NoCLNoWeld.FCStd
(62.01 KiB) Downloaded 18 times
2LineCLTest_NoCL.FCStd
(76.28 KiB) Downloaded 15 times
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: [Bug?] Recent FreeCAD crashes when opening a file with TechDraw page made with the same version

Post by aapo »

wandererfan wrote: Tue Nov 05, 2019 10:01 pm CenterLines seem to be thoroughly broken. Stay away from them while I sort things out.
No worries, I understand they are experimental development at the moment. And they are already so useful in their slightly broken form, that I rather use them than not. So, I find them a very welcome addition to FreeCAD even now! :) Also, I use a version control system, and utilize the save-early-save-often methodology, and put all my parts in their own files. I also have quite a list of FreeCAD daily compilations ready, so I can try with different FreeCAD versions, so that I can try to work around any bugs. Thus, I believe I'm pretty well prepared to handle any possible file corruption problems. :)

I just wanted to share everything I've learned about the much welcome, but bit problematic, CenterLines. Generally they seem to work very well, until one either a) edits the 3D geometry or b) makes a save-close-load cycle. In my experience, both cases can lead to crashes, CenterLine weirdnesses, or FCStd file corruption. This leads me to believe that the problem lies with the 3D shape to 2D curve projection, and is caused by the infamous FreeCAD-wide Toponaming issue. My hypothesis is that rebuilding the drawing in the save-close-load cycle sometimes causes the edge (or face) numbering to change for some reason, even though the underlying geometry does not change. There is no guarantee for the edge order to stay constant, even if the 3D geometry "looks the same", right? I've noticed that the save-close-load cycle sometimes also makes some number of the dimensions corrupted, but this does not generally cause crashes. It's still bit inconvenient, when the save-close-load cycle makes your dimensions to jump all over. But unfortunately I've yet to manage to isolate a simple, repeatable example, showing how to exactly trigger this phenomenon. Anyway, I suspect that the CenterLine bug is caused by the same rather randomly occurring phenomenon, but it has more serious side effects, because the needed input validations are missing for CenterLines.


WeldingSymbol is having trouble with finding the Svg icons. They are visible to the file manager, but TD says they aren't there.
Curiously, the WeldingSymbols still seem to be able to print the icons on screen. Sometimes the WeldingSymbols jump around the document tree in a weird way, I suppose they should stay children to the DrawLeaderLine in the document tree, but more often than not they end up in the document tree root. On the drawing they still show up at the correct place.


Repaired versions of your file attached - one with no centerlines, and one with no centerlines and no welding. They open here with freecad-daily.
Thanks! That saved me some trouble with re-editing with the old version 0.19.508. :)
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [Bug?] Recent FreeCAD crashes when opening a file with TechDraw page made with the same version

Post by wmayer »

In case it helps to get the crash fixed I found a bug in the function CenterLine::calcEndPoints2Lines. In the for-loop it does:

Code: Select all

        TechDraw::BaseGeom* bg = partFeat->getGeomByIndex(idx);
        edges.push_back(bg);
but it doesn't check if "bg" is null and simply adds it to the array. Afterwards it calls

Code: Select all

Base::Vector3d l1p1 = edges.front()->getStartPoint();
and because the first element is null it causes a segmentation fault.

So, the solution is very simple: check that "bg" is not null before adding it to "edges".
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Bug?] Recent FreeCAD crashes when opening a file with TechDraw page made with the same version

Post by wandererfan »

wmayer wrote: Wed Nov 06, 2019 9:29 am In case it helps to get the crash fixed I found a bug in the function CenterLine::calcEndPoints2Lines. In the for-loop it does:
Thanks. That saves me some time.
Post Reply