Ticket #4164 - Crash when opening a document using "Recent files" without creating a new document before

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
chrisb
Posts: 19562
Joined: Tue Mar 17, 2015 9:14 am

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby chrisb » Mon Oct 07, 2019 5:42 pm

kisolre wrote:
Mon Oct 07, 2019 11:58 am
Cant confirm here also
So it is indeed time to reset the configuration with the button in the preferences. Another possibility is to delete your config files or to move them in case you want to restore them.
tom
Posts: 65
Joined: Sun Mar 29, 2015 9:20 pm

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby tom » Mon Oct 07, 2019 6:30 pm

wmayer wrote:
Mon Oct 07, 2019 5:36 pm
This is what I have guessed too but the only problem is that strncpy doesn't occur inside c_glglue_instance. It's used inside the function glglue_set_glVersion() which is invoked from within c_glglue_instance but then in the call stack glglue_set_glVersion() should occur, too.
I guess that glglue_set_glVersion is simply inlined. In that case it doesn't appear on the stack.
tom
Posts: 65
Joined: Sun Mar 29, 2015 9:20 pm

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby tom » Mon Oct 07, 2019 6:37 pm

chrisb wrote:
Mon Oct 07, 2019 5:42 pm
kisolre wrote:
Mon Oct 07, 2019 11:58 am
Cant confirm here also
So it is indeed time to reset the configuration with the button in the preferences. Another possibility is to delete your config files or to move them in case you want to restore them.
As I already wrote in my previous mail from 6:10 PM it is indeed configuration related. So, there are three pre-conditions to reproduce the crash:
  • auto load module must be configured to "Part Design"
  • FC must be freshly started, i.e. no document must be open
  • one must use the "Recent files" menu to open a document
BR Thomas
kisolre
Posts: 1360
Joined: Wed Nov 21, 2018 1:13 pm

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby kisolre » Mon Oct 07, 2019 6:53 pm

tom wrote:
Mon Oct 07, 2019 6:37 pm
As I already wrote in my previous mail from 6:10 PM it is indeed configuration related. So, there are three pre-conditions to reproduce the crash:
auto load module must be configured to "Part Design"
FC must be freshly started, i.e. no document must be open
one must use the "Recent files" menu to open a document
All three met here, no crash. It might be only Mac related?
wmayer
Site Admin
Posts: 14991
Joined: Thu Feb 19, 2009 10:32 am

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby wmayer » Mon Oct 07, 2019 8:31 pm

tom wrote:
Mon Oct 07, 2019 6:30 pm
wmayer wrote:
Mon Oct 07, 2019 5:36 pm
This is what I have guessed too but the only problem is that strncpy doesn't occur inside c_glglue_instance. It's used inside the function glglue_set_glVersion() which is invoked from within c_glglue_instance but then in the call stack glglue_set_glVersion() should occur, too.
I guess that glglue_set_glVersion is simply inlined. In that case it doesn't appear on the stack.
Yes, that could be the case. c_glglue_instance is part of Coin's API while glglue_set_glVersion isn't and it's a global function inside the gl.cpp file.
chrisb
Posts: 19562
Joined: Tue Mar 17, 2015 9:14 am

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby chrisb » Mon Oct 07, 2019 9:11 pm

I can confirm the crash with Autoload=PartDesign.

OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18403 (Git)
Build type: Release
Branch: master
Hash: 0717b4fc23ef1db70964c3977d25e2fe46a739d1
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Germany (en_DE)
leonardshelby
Posts: 50
Joined: Sat Feb 24, 2018 6:09 pm

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby leonardshelby » Thu Oct 10, 2019 3:41 pm

I can also confirm the crash with Autoload=PartDesign.

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18403 (Git)
Build type: Release
Branch: master
Hash: 0717b4fc23ef1db70964c3977d25e2fe46a739d1
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Germany (en_DE)
tom
Posts: 65
Joined: Sun Mar 29, 2015 9:20 pm

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby tom » Sat Oct 12, 2019 6:30 pm

I compiled FC in debug configuration and started it in a debugger. Now it stops at an assertion point in QuarterWidget.cpp:889:

Code: Select all

frame #4: 0x0000000100a65b25 libFreeCADGui.dylib`SIM::Coin3D::Quarter::QuarterWidget::paintEvent(this=0x0000000108bd7c00, event=0x00007ffeefbeae90) at QuarterWidget.cpp:889
   886 	    glMatrixMode(GL_PROJECTION);
   887 	
   888 	    QtGLWidget* w = static_cast<QtGLWidget*>(this->viewport());
-> 889 	    assert(w->isValid() && "No valid GL context found!");
   890 	    // We might have to process the delay queue here since we don't know
   891 	    // if paintGL() is called from Qt, and we might have some sensors
   892 	    // waiting to trigger (the redraw sensor has a lower priority than a
(lldb) p w
(CustomGLWidget *) $0 = 0x0000000130418bb0
(lldb) p *w
(QtGLWidget) $1 = {
  QWidget = {
    QObject = {
      d_ptr = {
        d = 0x0000000130418bf0
      }
    }
    QPaintDevice = (painters = 0, reserved = 0x0000000000000000)
    data = 0x0000000130418d20
  }
}
(lldb)
I think the segmentation fault in release configuration is related to that assertion since the stack trace looks quite similar:

Code: Select all

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff75e1fb66 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff75fea080 libsystem_pthread.dylib`pthread_kill + 333
    frame #2: 0x00007fff75d7b1ae libsystem_c.dylib`abort + 127
    frame #3: 0x00007fff75d431ac libsystem_c.dylib`__assert_rtn + 320
    frame #4: 0x0000000100a65b25 libFreeCADGui.dylib`SIM::Coin3D::Quarter::QuarterWidget::paintEvent(this=0x0000000108bd7c00, event=0x00007ffeefbeae90) at QuarterWidget.cpp:889
    frame #5: 0x0000000100a70afd libFreeCADGui.dylib`SIM::Coin3D::Quarter::SoQTQuarterAdaptor::paintEvent(this=0x0000000108bd7c00, event=0x00007ffeefbeae90) at SoQTQuarterAdaptor.cpp:723
    frame #6: 0x0000000104ef41c8 QtWidgets`QWidget::event(QEvent*) + 1096
    frame #7: 0x0000000104f9a49d QtWidgets`QFrame::event(QEvent*) + 45
    frame #8: 0x000000010520fdb7 QtWidgets`QGraphicsView::viewportEvent(QEvent*) + 1191
    frame #9: 0x0000000100a65d60 libFreeCADGui.dylib`SIM::Coin3D::Quarter::QuarterWidget::viewportEvent(this=0x0000000108bd7c00, event=0x00007ffeefbeae90) at QuarterWidget.cpp:996
    frame #10: 0x0000000105b816a4 QtCore`QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 148
    frame #11: 0x0000000104eb87f8 QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 248
    frame #12: 0x0000000104eb9c12 QtWidgets`QApplication::notify(QObject*, QEvent*) + 594
    frame #13: 0x000000010046dbb6 libFreeCADGui.dylib`Gui::GUIApplication::notify(this=0x00007ffeefbfbf20, receiver=0x0000000130418bb0, event=0x00007ffeefbeae90) at GuiApplication.cpp:91
    frame #14: 0x0000000105b813f4 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 212
    frame #15: 0x0000000104eece4f QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 3135
    frame #16: 0x0000000104eed5c0 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 1120
    frame #17: 0x0000000104eecfb7 QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 3495
    frame #18: 0x0000000104eed5c0 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 1120
    frame #19: 0x0000000104eecfb7 QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 3495
    frame #20: 0x0000000104eed5c0 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 1120
    frame #21: 0x0000000104eecfb7 QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 3495
    frame #22: 0x0000000104eed5c0 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 1120
    frame #23: 0x0000000104eecfb7 QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 3495
    frame #24: 0x0000000104eed5c0 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 1120
    frame #25: 0x0000000104eecfb7 QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 3495
    frame #26: 0x0000000104eed5c0 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 1120
...
Any ideas why the GL context is invalid here?

BR Thomas
tom
Posts: 65
Joined: Sun Mar 29, 2015 9:20 pm

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby tom » Sat Oct 12, 2019 6:43 pm

Just looked at the documentation of QOpenGLWidget::isValid() and found an interesting note:
bool QOpenGLWidget::isValid() const

Returns true if the widget and OpenGL resources, like the context, have been successfully initialized. Note that the return value is always false until the widget is shown.
I assume that the mentioned QOpenGLWidget is the canvas for the 3D view, which is in the current scenario not visible yet. Perhaps it would be enough to show a empty canvas first before rending the opened document?
User avatar
Kunda1
Posts: 5916
Joined: Thu Jan 05, 2017 9:03 pm

Re: Crash when opening a document using "Recent files" without creating a new document before

Postby Kunda1 » Sat Oct 12, 2019 10:41 pm

Please open a ticket on the tracker for this bug. Thanks!
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features