View Issue Details

IDProjectCategoryView StatusLast Update
0002134FreeCADBugpublic2015-12-15 13:18
ReporterSanguinario_JoeAssigned Towmayer 
PriorityhighSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Platform64-bitOSLinux/KubuntuOS Version14.04.2 LTS
Product Version0.15 
Target VersionFixed in Version0.16 
Summary0002134: FreeCAD crashes when the window is restored and a plot is shown
DescriptionPlot module is causing a program crash when the Program is minimized and restored back later.
Steps To ReproduceIn the Python script view:
import Plot
Plot.plot([0,1], [0,1])
Minimize the window, and restore it back
Additional InformationGDB returns the following backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5584a4d in QWidget::windowTitle() const () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
(gdb) backtrace
#0 0x00007ffff5584a4d in QWidget::windowTitle() const () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#1 0x00007ffff73ba2ac in Gui::Application::viewActivated (this=0x7fffffffc9e0, pcView=0x0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Application.cpp:897
0000002 0x00007ffff76a90ee in Gui::MainWindow::changeEvent (this=0x7fffffffc800, e=0x7fffffffbde0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/MainWindow.cpp:1468
0000003 0x00007ffff5590cd0 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000004 0x00007ffff594b9b3 in QMainWindow::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000005 0x00007ffff76a2529 in Gui::MainWindow::event (this=0x7fffffffc800, e=0x7fffffffbde0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/MainWindow.cpp:623
0000006 0x00007ffff5541e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000007 0x00007ffff55484a0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000008 0x00007ffff73c4297 in Gui::GUIApplication::notify (this=0x7fffffffc830, receiver=0x7fffffffc800, event=0x7fffffffbde0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Application.cpp:1547
0000009 0x00007ffff4dcb4dd in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000010 0x00007ffff5546b44 in QApplication::setActiveWindow(QWidget*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000011 0x00007ffff55bbbe1 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000012 0x00007ffff55e3b02 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000013 0x00007fffee279e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000014 0x00007fffee27a048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000015 0x00007fffee27a0ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000016 0x00007ffff4df87a1 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000017 0x00007ffff55e3bb6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000018 0x00007ffff4dca0af in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000019 0x00007ffff4dca3a5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000020 0x00007ffff4dcfb79 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000021 0x00007ffff73bf9c9 in Gui::Application::runApplication () at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Application.cpp:1822
0000022 0x0000000000408508 in main (argc=1, argv=0x7fffffffd1c8) at /home/pepe/FreeCAD/freecad.cmake/src/Main/MainGui.cpp:328
TagsNo tags attached.

Activities

Sanguinario_Joe

2015-05-31 13:14

developer   ~0006170

OS: Ubuntu 14.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.5036 (Git)
Build type: Debug
Branch: sanguinariojoe-ship
Hash: a12f700aa27792f0ecdf09c5ee190d0bf88b0e81
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a

Sanguinario_Joe

2015-05-31 13:49

developer   ~0006171

The problem comes from the line src/Gui/MainWindow.cpp:1463

MDIView* view =dynamic_cast<MDIView*>(mdi->widget());

While mdi->widget() has an actual memory address, view is nil, which of course will cause that Application::Instance->viewActivated(view) fail getting the window title.

Sanguinario_Joe

2015-05-31 14:40

developer   ~0006172

Replacing the line by just a variable reinterpretation:

MDIView* view = (MDIView*)(mdi->widget());

It seems to pass OK through the problem, however it is exploding later anyway:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff73e3fc3 in Gui::Document::getDocument (this=0x25802b0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Document.cpp:575
575 return d->_pcDocument;
(gdb) backtrace
#0 0x00007ffff73e3fc3 in Gui::Document::getDocument (this=0x25802b0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Document.cpp:575
#1 0x00007ffff73b9a08 in Gui::Application::setActiveDocument (this=0x7fffffffc9e0, pcDocument=0x25802b0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Application.cpp:772
0000002 0x00007ffff73ba389 in Gui::Application::viewActivated (this=0x7fffffffc9e0, pcView=0x25d7cc0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Application.cpp:910
0000003 0x00007ffff76a916b in Gui::MainWindow::changeEvent (this=0x7fffffffc800, e=0x7fffffffbde0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/MainWindow.cpp:1472
0000004 0x00007ffff5590cd0 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000005 0x00007ffff594b9b3 in QMainWindow::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000006 0x00007ffff76a257d in Gui::MainWindow::event (this=0x7fffffffc800, e=0x7fffffffbde0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/MainWindow.cpp:623
0000007 0x00007ffff5541e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000008 0x00007ffff55484a0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000009 0x00007ffff73c42eb in Gui::GUIApplication::notify (this=0x7fffffffc830, receiver=0x7fffffffc800, event=0x7fffffffbde0) at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Application.cpp:1552
0000010 0x00007ffff4dcb4dd in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000011 0x00007ffff5546b44 in QApplication::setActiveWindow(QWidget*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000012 0x00007ffff55bbbe1 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000013 0x00007ffff55e3b02 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000014 0x00007fffee279e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000015 0x00007fffee27a048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000016 0x00007fffee27a0ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000017 0x00007ffff4df87a1 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000018 0x00007ffff55e3bb6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000019 0x00007ffff4dca0af in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000020 0x00007ffff4dca3a5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000021 0x00007ffff4dcfb79 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000022 0x00007ffff73bfa1d in Gui::Application::runApplication () at /home/pepe/FreeCAD/freecad.cmake/src/Gui/Application.cpp:1827
0000023 0x0000000000408508 in main (argc=1, argv=0x7fffffffd1c8) at /home/pepe/FreeCAD/freecad.cmake/src/Main/MainGui.cpp:328

GDB say that d points to an invalid address. I'm trying to figure out what's going on

wmayer

2015-05-31 15:21

administrator   ~0006174

> MDIView* view =dynamic_cast<MDIView*>(mdi->widget());
Hmm, this happens when adding any other widget to the QMdiArea. However, it is correct to use the C++ dynamic_cast as this correctly returns a null pointer if the widget of the QMdiSubWindow doesn't inherit from MDIView.

> MDIView* view = (MDIView*)(mdi->widget());
That's definitely worse because it gives you a dangling pointer that causes undefined behaviour.

Related Changesets

FreeCAD: master 2e14552a

2015-05-31 17:29:30

wmayer

Details Diff
+ fixes 0002134: FreeCAD crashes when the window is restored and a plot is shown Affected Issues
0002134
mod - src/Gui/MainWindow.cpp Diff File

Issue History

Date Modified Username Field Change
2015-05-31 13:13 Sanguinario_Joe New Issue
2015-05-31 13:14 Sanguinario_Joe Note Added: 0006170
2015-05-31 13:49 Sanguinario_Joe Note Added: 0006171
2015-05-31 14:40 Sanguinario_Joe Note Added: 0006172
2015-05-31 15:21 wmayer Note Added: 0006174
2015-05-31 15:30 wmayer Changeset attached => FreeCAD Master master 2e14552a
2015-05-31 15:30 wmayer Assigned To => wmayer
2015-05-31 15:30 wmayer Status new => closed
2015-05-31 15:30 wmayer Resolution open => fixed
2015-12-15 13:18 yorik Fixed in Version => 0.16