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
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

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

Post by chrisb »

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.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
tom
Posts: 165
Joined: Sun Mar 29, 2015 9:20 pm

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

Post by tom »

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: 165
Joined: Sun Mar 29, 2015 9:20 pm

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

Post by tom »

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
Veteran
Posts: 4162
Joined: Wed Nov 21, 2018 1:13 pm

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

Post by kisolre »

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
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

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

Post by wmayer »

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
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

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

Post by chrisb »

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)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
leonardshelby
Posts: 73
Joined: Sat Feb 24, 2018 6:09 pm

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

Post by leonardshelby »

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: 165
Joined: Sun Mar 29, 2015 9:20 pm

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

Post by tom »

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: 165
Joined: Sun Mar 29, 2015 9:20 pm

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

Post by tom »

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
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

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

Post by Kunda1 »

Please open a ticket on the tracker for this bug. Thanks!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply