Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4311 closed defect (fixed)

OMEdit segfault after start

Reported by: spinnau@… Owned by: Adeel Asghar
Priority: low Milestone: 1.12.0
Component: OMEdit Version:
Keywords: Cc:

Description

OMEdit built from master branch terminates immediately on startup. After the splash screen the main window is shown for approx. 1 second.

System: Linux x64 with Qt 5.8.0

$ git describe --long
v1.12.0-dev-513-gc9b965391
Core was generated by `OMEdit'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f878b3b47a0 in operator==(QString const&, QString const&) () from /usr/lib/libQt5Core.so.5
[Current thread is 1 (Thread 0x7f879394c940 (LWP 22532))]
(gdb) bt
#0  0x00007f878b3b47a0 in operator==(QString const&, QString const&) () at /usr/lib/libQt5Core.so.5
#1  0x00007f878ced93e7 in QLabel::setText(QString const&) () at /usr/lib/libQt5Widgets.so.5
#2  0x00007f878cf8d383 in  () at /usr/lib/libQt5Widgets.so.5
#3  0x00007f878cf8e8fe in QColorDialog::changeEvent(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#4  0x00007f878cdecc34 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#5  0x00007f878cda534c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#6  0x00007f878cdacb61 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#7  0x00007f878b50e440 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#8  0x00007f878cdecc79 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#9  0x00007f878cf1b513 in QMenu::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#10 0x00007f878cda534c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#11 0x00007f878cdacb61 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#12 0x00007f878b50e440 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#13 0x00007f878b510bcd in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5
#14 0x00007f878b562c43 in  () at /usr/lib/libQt5Core.so.5
#15 0x00007f8785b765a7 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#16 0x00007f8785b76810 in  () at /usr/lib/libglib-2.0.so.0
#17 0x00007f8785b768bc in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#18 0x00007f878b56304f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#19 0x00007f878b50c89a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#20 0x00007f878cf93917 in QDialog::exec() () at /usr/lib/libQt5Widgets.so.5
#21 0x00000000004f9c32 in signalHandler(int) ()
#22 0x00007f878a445a90 in <signal handler called> () at /usr/lib/libc.so.6
#23 0x00007f878ced93c4 in QLabel::setText(QString const&) () at /usr/lib/libQt5Widgets.so.5
#24 0x00007f878cf8c7cb in  () at /usr/lib/libQt5Widgets.so.5
#25 0x00007f878cf8d330 in  () at /usr/lib/libQt5Widgets.so.5
#26 0x00007f878cf8e8fe in QColorDialog::changeEvent(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#27 0x00007f878cdecc34 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#28 0x00007f878cda534c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#29 0x00007f878cdacb61 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#30 0x00007f878b50e440 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#31 0x00007f878cdecc79 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#32 0x00007f878cf1b513 in QMenu::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#33 0x00007f878cda534c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#34 0x00007f878cdacb61 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#35 0x00007f878b50e440 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#36 0x00007f878b510bcd in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5
#37 0x00007f878b562c43 in  () at /usr/lib/libQt5Core.so.5
#38 0x00007f8785b765a7 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#39 0x00007f8785b76810 in  () at /usr/lib/libglib-2.0.so.0
#40 0x00007f8785b768bc in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#41 0x00007f878b56304f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#42 0x00007f878b50c89a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#43 0x00007f878b514de4 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#44 0x00000000004fa0a7 in main ()
(gdb) 
$ ldd /usr/bin/OMEdit 
	linux-vdso.so.1 (0x00007ffea05e3000)
	libOMPlot.so.1 => /usr/bin/../lib/x86_64-linux-gnu/omc/libOMPlot.so.1 (0x00007fa764c65000)
	libomqwt.so.6 => /usr/bin/../lib/x86_64-linux-gnu/omc/libomqwt.so.6 (0x00007fa764918000)
	libfmilib_shared.so => /usr/bin/../lib/x86_64-linux-gnu/omc/libfmilib_shared.so (0x00007fa76468c000)
	libomantlr3.so => /usr/bin/../lib/x86_64-linux-gnu/omc/libomantlr3.so (0x00007fa764474000)
	libOpenModelicaCompiler.so => /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so (0x00007fa762eb1000)
	libOpenModelicaRuntimeC.so => /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaRuntimeC.so (0x00007fa762c47000)
	libomcgc.so.1 => /usr/bin/../lib/x86_64-linux-gnu/omc/libomcgc.so.1 (0x00007fa7628e3000)
	libosg.so.130 => /usr/lib/libosg.so.130 (0x00007fa7623a4000)
	libosgViewer.so.130 => /usr/lib/libosgViewer.so.130 (0x00007fa7620a5000)
	libosgDB.so.130 => /usr/lib/libosgDB.so.130 (0x00007fa761d57000)
	libosgGA.so.130 => /usr/lib/libosgGA.so.130 (0x00007fa761aad000)
	libqjson.so.0 => /usr/bin/../lib/x86_64-linux-gnu/omc/libqjson.so.0 (0x00007fa761881000)
	libQt5WebKitWidgets.so.5 => /usr/lib/libQt5WebKitWidgets.so.5 (0x00007fa76163c000)
	libQt5WebKit.so.5 => /usr/lib/libQt5WebKit.so.5 (0x00007fa75f014000)
	libQt5Svg.so.5 => /usr/lib/libQt5Svg.so.5 (0x00007fa75edc0000)
	libQt5PrintSupport.so.5 => /usr/lib/libQt5PrintSupport.so.5 (0x00007fa75eb50000)
	libQt5Widgets.so.5 => /usr/lib/libQt5Widgets.so.5 (0x00007fa75e2f6000)
	libQt5Gui.so.5 => /usr/lib/libQt5Gui.so.5 (0x00007fa75dbbb000)
	libQt5XmlPatterns.so.5 => /usr/lib/libQt5XmlPatterns.so.5 (0x00007fa75d5cc000)
	libQt5Network.so.5 => /usr/lib/libQt5Network.so.5 (0x00007fa75d241000)
	libQt5Xml.so.5 => /usr/lib/libQt5Xml.so.5 (0x00007fa75d006000)
	libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0x00007fa75c92a000)
	libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fa75c70c000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fa75c384000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007fa75c071000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fa75be5a000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007fa75bab6000)
	libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fa75b8b2000)
	libomcruntime.so => /usr/bin/../lib/x86_64-linux-gnu/omc/libomcruntime.so (0x00007fa75b5be000)
	libModelicaExternalC.so.0 => /usr/bin/../lib/x86_64-linux-gnu/omc/libModelicaExternalC.so.0 (0x00007fa75b3b2000)
	libomniORB4.so.2 => /usr/lib/libomniORB4.so.2 (0x00007fa75aff5000)
	libomnithread.so.4 => /usr/lib/libomnithread.so.4 (0x00007fa75adef000)
	libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007fa75abc5000)
	libhwloc.so.5 => /usr/lib/libhwloc.so.5 (0x00007fa75a989000)
	libuuid.so.1 => /usr/lib/libuuid.so.1 (0x00007fa75a784000)
	liblapack.so.3 => /usr/lib/liblapack.so.3 (0x00007fa759ea5000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fa764eb3000)
	libatomic_ops.so.1 => /usr/lib/libatomic_ops.so.1 (0x00007fa759ca2000)
	libOpenThreads.so.20 => /usr/lib/libOpenThreads.so.20 (0x00007fa759a9a000)
	librt.so.1 => /usr/lib/librt.so.1 (0x00007fa759892000)
	libGL.so.1 => /usr/lib/libGL.so.1 (0x00007fa759607000)
	libosgText.so.130 => /usr/lib/libosgText.so.130 (0x00007fa75939f000)
	libosgUtil.so.130 => /usr/lib/libosgUtil.so.130 (0x00007fa758f86000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0x00007fa758c47000)
	libz.so.1 => /usr/lib/libz.so.1 (0x00007fa758a30000)
	libQt5Sensors.so.5 => /usr/lib/libQt5Sensors.so.5 (0x00007fa7587f3000)
	libQt5OpenGL.so.5 => /usr/lib/libQt5OpenGL.so.5 (0x00007fa75859b000)
	libXcomposite.so.1 => /usr/lib/libXcomposite.so.1 (0x00007fa758398000)
	libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00007fa75818d000)
	libjpeg.so.8 => /usr/lib/libjpeg.so.8 (0x00007fa757f23000)
	libpng16.so.16 => /usr/lib/libpng16.so.16 (0x00007fa757ced000)
	libwebp.so.6 => /usr/lib/libwebp.so.6 (0x00007fa757a8b000)
	libxslt.so.1 => /usr/lib/libxslt.so.1 (0x00007fa75784b000)
	libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007fa7574e3000)
	libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007fa7571d0000)
	libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007fa756f7e000)
	libgstreamer-1.0.so.0 => /usr/lib/libgstreamer-1.0.so.0 (0x00007fa756c4c000)
	libgstapp-1.0.so.0 => /usr/lib/libgstapp-1.0.so.0 (0x00007fa756a3e000)
	libgstbase-1.0.so.0 => /usr/lib/libgstbase-1.0.so.0 (0x00007fa7567da000)
	libgstpbutils-1.0.so.0 => /usr/lib/libgstpbutils-1.0.so.0 (0x00007fa7565a5000)
	libgstvideo-1.0.so.0 => /usr/lib/libgstvideo-1.0.so.0 (0x00007fa75631a000)
	libgstaudio-1.0.so.0 => /usr/lib/libgstaudio-1.0.so.0 (0x00007fa7560af000)
	libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00007fa755d9c000)
	libicui18n.so.58 => /usr/lib/libicui18n.so.58 (0x00007fa755922000)
	libicuuc.so.58 => /usr/lib/libicuuc.so.58 (0x00007fa755576000)
	libQt5Positioning.so.5 => /usr/lib/libQt5Positioning.so.5 (0x00007fa755336000)
	libQt5Quick.so.5 => /usr/lib/libQt5Quick.so.5 (0x00007fa754cfa000)
	libQt5Qml.so.5 => /usr/lib/libQt5Qml.so.5 (0x00007fa7546f6000)
	libQt5WebChannel.so.5 => /usr/lib/libQt5WebChannel.so.5 (0x00007fa7544d8000)
	libQt5Sql.so.5 => /usr/lib/libQt5Sql.so.5 (0x00007fa754290000)
	libharfbuzz.so.0 => /usr/lib/libharfbuzz.so.0 (0x00007fa754000000)
	libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007fa753d8e000)
	libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007fa753916000)
	libsystemd.so.0 => /usr/lib/libsystemd.so.0 (0x00007fa765009000)
	libpcre16.so.0 => /usr/lib/libpcre16.so.0 (0x00007fa7536ad000)
	liblpsolve55.so => /usr/lib/liblpsolve55.so (0x00007fa753419000)
	libnuma.so.1 => /usr/lib/libnuma.so.1 (0x00007fa75320d000)
	libltdl.so.7 => /usr/lib/libltdl.so.7 (0x00007fa753003000)
	libblas.so.3 => /usr/lib/libblas.so.3 (0x00007fa752dad000)
	libgfortran.so.3 => /usr/lib/libgfortran.so.3 (0x00007fa752a7c000)
	libGLX.so.0 => /usr/lib/libGLX.so.0 (0x00007fa75284b000)
	libXext.so.6 => /usr/lib/libXext.so.6 (0x00007fa752639000)
	libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x00007fa752383000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007fa75215a000)
	liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007fa751f34000)
	libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007fa751cc1000)
	libffi.so.6 => /usr/lib/libffi.so.6 (0x00007fa751ab8000)
	libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x00007fa7518b4000)
	libgsttag-1.0.so.0 => /usr/lib/libgsttag-1.0.so.0 (0x00007fa75167a000)
	liborc-0.4.so.0 => /usr/lib/liborc-0.4.so.0 (0x00007fa7513fc000)
	libicudata.so.58 => /usr/lib/libicudata.so.58 (0x00007fa74f8fc000)
	libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007fa74f63b000)
	libgraphite2.so.3 => /usr/lib/libgraphite2.so.3 (0x00007fa74f40f000)
	libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007fa74f1f9000)
	libcap.so.2 => /usr/lib/libcap.so.2 (0x00007fa74eff5000)
	liblz4.so.1 => /usr/lib/liblz4.so.1 (0x00007fa74ede1000)
	libgcrypt.so.20 => /usr/lib/libgcrypt.so.20 (0x00007fa74ead2000)
	libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0x00007fa74e8bd000)
	libquadmath.so.0 => /usr/lib/../lib/libquadmath.so.0 (0x00007fa74e67d000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0x00007fa74e479000)
	libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007fa74e273000)
	libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007fa74e063000)

Running an older version v1.12.0.dev.r253.g2f5803d0e works fine with the installed libraries. But I haven't bisected when the problem was introduced.

Change History (10)

comment:1 by spinnau@…, 8 years ago

I have bisected the OpenModelica commits to find the problem. Test builds were always compiled using the corresponding subrepos:

$ git bisect [good|bad]
$ git submodule update --recursive
$ ./configure
$ make omedit

The commit that introduced the problem is fd8921a

commit fd8921a05e1887841768ca5ae01422258e082252

    * OMEdit e814eb1...9f7a31d (2):
      > Fix builds.
      > ticket:4164 Subclass QApplication to handle QFileOpenEvent for OSX.

OMEdit from this version crashes immediatley after the main window occurs with this backtrace:

Thread 1 "OMEdit" received signal SIGSEGV, Segmentation fault.
0x00007ffff10123c4 in QLabel::setText(QString const&) () from /usr/lib/libQt5Widgets.so.5
(gdb) bt
#0  0x00007ffff10123c4 in QLabel::setText(QString const&) () at /usr/lib/libQt5Widgets.so.5
#1  0x00007ffff10c6383 in  () at /usr/lib/libQt5Widgets.so.5
#2  0x00007ffff10c78fe in QColorDialog::changeEvent(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#3  0x00007ffff0f25c34 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#4  0x00007ffff0ede34c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#5  0x00007ffff0ee5b61 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#6  0x00007fffef647440 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#7  0x00007ffff0f25c79 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#8  0x00007ffff1054513 in QMenu::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#9  0x00007ffff0ede34c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#10 0x00007ffff0ee5b61 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#11 0x00007fffef647440 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#12 0x00007fffef649bcd in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5
#13 0x00007fffef69bc43 in  () at /usr/lib/libQt5Core.so.5
#14 0x00007fffe9c2a5a7 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#15 0x00007fffe9c2a810 in  () at /usr/lib/libglib-2.0.so.0
#16 0x00007fffe9c2a8bc in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#17 0x00007fffef69c04f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#18 0x00007fffef64589a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#19 0x00007fffef64dde4 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#20 0x0000000000565941 in main(int, char**) (argc=1, argv=0x7fffffffe6e8) at main.cpp:170
(gdb) 

comment:2 by Adeel Asghar, 8 years ago

Priority: highlow

Well we don't currently support Qt 5.8 so unfortunately we can't help here. You have to provide a pull request with a fix.

I also don't see any OMEdit file causing the segmentation fault in the backtrace. Might be some event need to handled for Qt 5.8 but I am not sure.

comment:3 by spinnau@…, 8 years ago

I have figured this out. Inside of OMEditApplication's constructor two QTranslator objects will be created on the stack. They get out of scope and will be destroyed after the constructor is finished. Thus, later access to it will cause crashing of OMEdit as I have experienced with Qt 5.8

I am not sure, why the crash after startup doesn't occur for Qt versions prior to 5.8, but these versions should also be affected if QApplication's translate() method is called later again, e.g. after creating new widgets.

OMEdit before commit 36812d4 works fine with Qt 5.8, as the QTranslator objects were instantiated in the main() function and therefore lives until the main event loop is stopped.

The solution would be to create the QTranslation objects on heap and set OMEditApplication as parent, so that the objects will be automatically detroyed if the application is closed. I have created an Pull Request for this.

comment:4 by Adeel Asghar, 8 years ago

Milestone: Future1.12.0
Resolution: fixed
Status: newclosed

Thanks for the fix. I have merged the PR.

Your explanation makes perfect sense but I just wonder why it is working with Qt versions prior to 5.8. Perhaps Qt has changed the way it looks for translation strings when translate() is called.

We also need to update OMNotebook in the same way. I will take care of it.

comment:5 by spinnau@…, 8 years ago

Maybe things will be done in parallel and translation is not completed yet, when MainWindow shows up and OMEditApplication's constructor finishes. But I have not found any relevant information on the Qt 5.8 changelog.

I just noticed that you have named all pointer variables with a leading p. I'm sorry I missed this. Maybe you want to change qtTranslator to pQtTranslator and translator to pTranslator to match this scheme. I can also create another PR for this.

comment:6 by Adeel Asghar, 8 years ago

Ah don't bother. I will do that.

comment:7 by Henning Kiel, 8 years ago

@adeas31 please don't forget to fix OMShell as well...

comment:8 by Adeel Asghar, 8 years ago

We don't need to do the same for OMNotebook and OMShell.

In OMNotebook translator and qtTranslator are defined as member variables of CellApplication so they are present until CellApplication is alive. And in OMShell they are defined in the main function.

comment:9 by spinnau@…, 8 years ago

OMNotebook and OMShell both compiles and start fine with Qt 5.8, but I didn't any further testing.

When allocating QObjects (with parent) on stack you have to take care on the order of construction/destruction. Otherwise this can cause errors if the QObject was already destroyed with its parent and the destructor is called again when the QObject goes out of scope (please see http://doc.qt.io/qt-5/objecttrees.html). Thus, creating the objects on the heap with *new* and let Qt manage the lifetime with object trees and parent-child-relationships might be less prone to errors.

comment:10 by Adeel Asghar, 8 years ago

Well in our case they are in order so its fine.

Also as you said you can compile and run both OMNotebook and OMShell so I guess we are safe.

Note: See TracTickets for help on using tickets.