FreeCAD crash after File->Revert

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
chrisb
Veteran
Posts: 54309
Joined: Tue Mar 17, 2015 9:14 am

FreeCAD crash after File->Revert

Post by chrisb »

The attached file contains a TechDraw page, which is opened automatically on opening the file. If I revert the file another TechDraw page is opened instead of reverting the existing page (which might already be a bug).
If I close the new TechDraw page FreeCAD crashes.

Steps to reproduce:
- Start FreeCAD
- open tdRot.fcstd
- move DefaultText with the mouse, e.g. to the middle of left top (x=60.398, y=157.572, but exact values don't matter)
- File->Revert (confirm with yes). Sometimes FreeCAD crashes already on this step
- delete the rightmost tab with the newly displayed TechDraw page
-> crash!
To be precise: on rare occasions it did not crash, but almost always.


OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14976 (Git)
Build type: Release
Branch: (HEAD detached at e79a19828)
Hash: e79a19828e2e92269ff96110dfeadaa245ad17c2
Python version: 2.7.15
Qt version: 5.11.2
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: German/Germany (de_DE)
Attachments
tdRot.FCStd
(13.4 KiB) Downloaded 40 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: FreeCAD crash after File->Revert

Post by ulrich1a »

I got FreeCAD to crash after a few trials too. The console had the following output:

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x33060) [0x7f63f9d83060]
#1  /usr/lib/x86_64-linux-gnu/libstdc++.so.6(__dynamic_cast+0xd) [0x7f63fa69792d]
#2  0x7f636dec8a69 in TechDrawGui::QGVPage::drawBackground(QPainter*, QRectF const&) from /home/ulrich/Sourcen/FreeCAD/build_7.2/Mod/TechDraw/TechDrawGui.so+0x29
#3  0x7f63fc0835b9 in QGraphicsView::paintEvent(QPaintEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0xc29
#4  0x7f636decacea in TechDrawGui::QGVPage::paintEvent(QPaintEvent*) from /home/ulrich/Sourcen/FreeCAD/build_7.2/Mod/TechDraw/TechDrawGui.so+0x1a
#5  0x7f63fba8ee80 in QWidget::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x290
#6  0x7f63fbe53c8e in QFrame::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x1e
#7  0x7f63fc081b74 in QGraphicsView::viewportEvent(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x184
#8  0x7f63faf720a1 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x91
#9  0x7f63fba3852c in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x6c
#10  0x7f63fba3f52c in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2cc
#11  0x7f64032ac441 in Gui::GUIApplication::notify(QObject*, QEvent*) from /home/ulrich/Sourcen/FreeCAD/build_7.2/lib/libFreeCADGui.so+0x41
#12  0x7f63faf71f1d in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x8d
#13  0x7f63fba894e5 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x605
#14  0x7f63fba89ed8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x458
#15  0x7f63fba89dd8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x358
#16  0x7f63fba89dd8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x358
#17  0x7f63fba89076 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x196
#18  0x7f63fba89ed8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x458
#19  0x7f63fba89076 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x196
#20  0x7f63fba89ed8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x458
#21  0x7f63fba89076 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x196
#22  0x7f63fba89ed8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x458
#23  0x7f63fba89076 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x196
#24  0x7f63fba89ed8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x458
#25  0x7f63fba89dd8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x358
#26  0x7f63fba89076 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x196
#27  0x7f63fba89ed8 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x458
#28  0x7f63fba89076 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x196
#29  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x3e564a) [0x7f63fbc5964a]
#30  0x7f63fba7c1e0 in QWidgetPrivate::syncBackingStore() from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0xa0
#31  0x7f63fba8ef68 in QWidget::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x378
#32  0x7f63fbe6e803 in QMainWindow::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x113
#33  0x7f64035405cb in Gui::MainWindow::event(QEvent*) from /home/ulrich/Sourcen/FreeCAD/build_7.2/lib/libFreeCADGui.so+0x5b
#34  0x7f63fba3854c in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x8c
#35  0x7f63fba3f52c in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2cc
#36  0x7f64032ac441 in Gui::GUIApplication::notify(QObject*, QEvent*) from /home/ulrich/Sourcen/FreeCAD/build_7.2/lib/libFreeCADGui.so+0x41
#37  0x7f63faf71f1d in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x8d
#38  0x7f63faf75a16 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x3b6
#39  /usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x1bb703) [0x7f63fafa2703]
#40  /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2a7) [0x7f63f270b7f7]
#41  /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4aa60) [0x7f63f270ba60]
#42  /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7f63f270bb0c]
#43  0x7f63fafa2854 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x64
#44  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26e5d6) [0x7f63fbae25d6]
#45  0x7f63faf707ef in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x3f
#46  0x7f63faf70b55 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x1b5
#47  0x7f63faf76bd9 in QCoreApplication::exec() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x99
#48  0x7f640325f777 in Gui::Application::runApplication() from /home/ulrich/Sourcen/FreeCAD/build_7.2/lib/libFreeCADGui.so+0x1997
#49  ./FreeCAD(main+0x851) [0x55ee7fa0b8a1]
#50  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7f63f9d702e1]
#51  ./FreeCAD(_start+0x2a) [0x55ee7fa0caca]
The log contained several times the following line.

Code: Select all

Log: INFO - ViewProviderPage::getMDIViewPage has no m_mdiView!
Ulrich

OS: Debian GNU/Linux 9.5 (stretch)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14996 (Git)
Build type: Release
Branch: Rueck6
Hash: f603f92f5a80be29b3cfdf32c2910869982bdc66
Python version: 2.7.13
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: German/Germany (de_DE)
chrisb
Veteran
Posts: 54309
Joined: Tue Mar 17, 2015 9:14 am

Re: FreeCAD crash after File->Revert

Post by chrisb »

Console output is here:

Code: Select all

*** Abort *** an exception was raised, but no catch was found.
	... The exception is:SIGSEGV 'segmentation violation' detected. Address 0
the adress is always different.

The log message cited by Ulrich

Code: Select all

Log: INFO - ViewProviderPage::getMDIViewPage has no m_mdiView!
is probably not the problem, because it occurs already multiple times in the log before the revert.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: FreeCAD crash after File->Revert

Post by vocx »

I can confirm the bug.

The triggering mechanism seems to be a bit different if the Menu > Edit > Preferences ... > TechDraw > TechDraw 1 > Keep Pages Up to Date option is disabled. In this case, the TechDraw Page doesn't appear from the beginning.
  1. In the model tree right click on the Page element and choose Show drawing.
  2. Select the annotation, and move it elsewhere
  3. Now, Menu > File > Revert
  4. "Do you want to continue?" Yes.
  5. The annotation disappears, leaving an empty template, but a second page is not created.
  6. Use the mouse wheel to zoom in or out. Crash!
I ran FreeCAD through the gdb debugger, and it seems the problem is on a type casting in C++.

Maybe when it tries to redraw the background with TechDrawGui::QGVPage::drawBackground() and TechDrawGui::QGVPage::paintEvent() in QGVPage.cpp?
https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L125

Code: Select all

Thread 1 "freecad-daily" received signal SIGSEGV, Segmentation fault.
0x00007ffff4cf435d in __dynamic_cast () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) n
Single stepping until exit from function __dynamic_cast,
which has no line number information.
0x00007ffff6ce8040 in segmentation_fault_handler(int) () from /usr/lib/freecad-daily/lib/libFreeCADApp.so
(gdb) n
Single stepping until exit from function _Z26segmentation_fault_handleri,
which has no line number information.
Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7ffff4698f20]
#1  /usr/lib/x86_64-linux-gnu/libstdc++.so.6(__dynamic_cast+0x1d) [0x7ffff4cf435d]
#2  0x7fff5b18cdef in TechDrawGui::QGVPage::drawBackground(QPainter*, QRectF const&) from /usr/lib/freecad-daily/lib/TechDrawGui.so+0x4f
#3  0x7ffff5cf3559 in QGraphicsView::paintEvent(QPaintEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0xc09
#4  0x7fff5b18f74a in TechDrawGui::QGVPage::paintEvent(QPaintEvent*) from /usr/lib/freecad-daily/lib/TechDrawGui.so+0x2a
#5  0x7ffff56f9930 in QWidget::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2a0
#6  0x7ffff5ac365e in QFrame::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x1e
#7  0x7ffff5cf1b3f in QGraphicsView::viewportEvent(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x17f
#8  0x7ffff5176a16 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x86
#9  0x7ffff56a301c in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x6c
#10  0x7ffff56a9f76 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2b6
#11  0x7ffff7314ae8 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x88
#12  0x7ffff51768ad in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x8d
#13  0x7ffff56f3f97 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x607
#14  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x3eadc8) [0x7ffff58c8dc8]
#15  0x7ffff56e6cb0 in QWidgetPrivate::syncBackingStore() from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0xa0
#16  0x7ffff56f9a18 in QWidget::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x388
#17  0x7ffff5ade323 in QMainWindow::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x113
#18  0x7ffff75dcf9b in Gui::MainWindow::event(QEvent*) from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x6b
#19  0x7ffff56a303c in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x8c
#20  0x7ffff56a9f76 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2b6
#21  0x7ffff7314ae8 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x88
#22  0x7ffff51768ad in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x8d
#23  0x7ffff517a366 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x376
#24  /usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x1bb09e) [0x7ffff51a709e]
#25  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2e7) [0x7fffedd26287]
#26  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4c4c0) [0x7fffedd264c0]
#27  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7fffedd2654c]
#28  0x7ffff51a720e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x7e
#29  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x272666) [0x7ffff5750666]
#30  0x7ffff517512f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x3f
#31  0x7ffff5175495 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x1b5
#32  0x7ffff517b459 in QCoreApplication::exec() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x99
#33  0x7ffff72be74e in Gui::Application::runApplication() from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x181e
#34  /usr/bin/freecad-daily(main+0x6db) [0x55555555741b]
#35  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7ffff467bb97]
#36  /usr/bin/freecad-daily(_start+0x2a) [0x5555555585ca]
If you don't activate the Keep Pages Up to Date option, after the step 5 above you can safely close the empty page. Then you can open it again, like in step 1, without crashing. However, as soon as you revert the file again, a repaint of the TechDraw background seems to trigger the crash.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD crash after File->Revert

Post by wmayer »

If I revert the file another TechDraw page is opened instead of reverting the existing page (which might already be a bug).
The bugs are related. When restoring a document then all its objects are destroyed and the document is read-in again. So, actually the open MDI view should be closed at this time and because it's not the internal view provider/document object are dangling pointers.
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: FreeCAD crash after File->Revert

Post by wandererfan »

chrisb
Veteran
Posts: 54309
Joined: Tue Mar 17, 2015 9:14 am

Re: FreeCAD crash after File->Revert

Post by chrisb »

wandererfan wrote: Sun Oct 21, 2018 6:14 pm Fix is in the queue: https://github.com/FreeCAD/FreeCAD/pull/1736
Thanks for the quick repair.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: FreeCAD crash after File->Revert

Post by vocx »

chrisb wrote: Sun Oct 21, 2018 9:10 pm
wandererfan wrote: Sun Oct 21, 2018 6:14 pm Fix is in the queue: https://github.com/FreeCAD/FreeCAD/pull/1736
Thanks for the quick repair.
It seems to be git commit 31a9ae6, and it made it to the latest version.

OS: Ubuntu 18.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15021 (Git)
Build type: Release
Branch: master
Hash: 2004653fe4ff6bc56bc29cfec84abdd4f6adf2c0
Python version: 2.7.15rc1
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply