Problem 1667

Summary: Segmentation Fault on SessionStart with Qt
Product: Geant4 Reporter: Joshua Ellis <coujellis>
Component: interfacesAssignee: Laurent Garnier <laurent.garnier>
Status: RESOLVED FIXED    
Severity: major CC: coujellis, garnier, laurent.garnier, olivier.delaune, padraig.looney
Priority: P5    
Version: 10.0   
Hardware: PC   
OS: Linux   
Attachments: PKGBUILD, gdb and valgrind reports.

Description Joshua Ellis 2014-08-23 01:42:59 CEST
Created attachment 280 [details]
PKGBUILD, gdb and valgrind reports.

I am running into a random segmentation fault when running `SessionStart()` from `G4UIExecutive`.  Unfortunately, I cannot seem to say much more than that.  It appears randomly, and sometimes will run perfectly fine though usually encounters a segfault.  I have tried it against exampleB1 to make sure it wasn't something I had done and the error is still there.

I am running Arch Linux, and Geant4 is using Qt5 v5.3.1.  I have tried this with Geant4 v10.00.p02 and Geant4 v10.01.b01; both have the error.

I have attached the PKGBUILD used to build Geant4, as well as the GDB backtraces for both versions of Geant4 when running exampleB1 (source taken from v10.01.b01).  I have also included Valgrind memchecks though interestingly, when Valgrind checks the memory the application doesn't crash.  Interestingly, there appear to be a few invalid reads in Valgrind by the same function that crashes according to GDB.

Please let me know if you would like any further information, or if you wish me to run any other tools to help debug this.

Lastly, it appears this issue is not just for me as a few others have reported similar issues over at https://aur.archlinux.org/packages/geant4/.  I have tried looking if this bug was already reported, but couldn't find anything.
Comment 1 Koichi Murakami 2014-09-24 07:54:59 CEST
The combination of MT and Qt is not well tested.
It might be a potential problem, I will check it.
Comment 2 Joshua Ellis 2014-10-26 03:18:32 CET
The issue doesn't appear to be (solely) related to the multithreaded feature.  I have recompiled Geant4 with multithreading off, recompiled the application, and this is the result:

Program received signal SIGFPE, Arithmetic exception.
0x00007fffe0bd0f3c in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
(gdb) where
#0  0x00007fffe0bd0f3c in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
#1  0x00007fffe0bd1d9c in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
#2  0x00007fffe0bd29a0 in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
#3  0x00007fffe0bb6ce7 in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
#4  0x00007fffe0bb8b8e in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
#5  0x00007fffe0bca44b in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
#6  0x00007fffef16d802 in QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&) ()
   from /usr/lib/libQt5Gui.so.5
#7  0x00007fffef179031 in QGuiApplicationPrivate::createPlatformIntegration() () from /usr/lib/libQt5Gui.so.5
#8  0x00007fffef179ccd in QGuiApplicationPrivate::createEventDispatcher() () from /usr/lib/libQt5Gui.so.5
#9  0x00007fffeec5a735 in QCoreApplication::init() () from /usr/lib/libQt5Core.so.5
#10 0x00007fffeec5a796 in QCoreApplication::QCoreApplication(QCoreApplicationPrivate&) () from /usr/lib/libQt5Core.so.5
#11 0x00007fffef17bf09 in QGuiApplication::QGuiApplication(QGuiApplicationPrivate&) () from /usr/lib/libQt5Gui.so.5
#12 0x00007fffef91046d in QApplication::QApplication(int&, char**, int) () from /usr/lib/libQt5Widgets.so.5
#13 0x00007ffff5d67f7f in G4Qt::G4Qt(int, char**, char*) () from /usr/lib/libG4interfaces.so
#14 0x00007ffff5d67db5 in G4Qt::getInstance(int, char**, char*) () from /usr/lib/libG4interfaces.so
#15 0x00007ffff5d4144b in G4UIQt::G4UIQt(int, char**) () from /usr/lib/libG4interfaces.so
#16 0x00007ffff5d37dfe in G4UIExecutive::G4UIExecutive(int, char**, G4String const&) () from /usr/lib/libG4interfaces.so
#17 0x000000000041985d in main (argc=1, argv=0x7fffffffd8b8) at /home/user/src/geant4/main.cc:98
Comment 3 Padraig 2015-03-04 16:01:06 CET
I have the same problem consitently in 4.1.0. 

I can start a session but it seems to be the line

/vis/open OGL 600x600-0+0

that is the source of the problem if included in a .mac file.

I can call this in the session ui no problem though.
Comment 4 Padraig 2015-03-09 10:13:26 CET
This may be a Qt5 issue. I've gotten the multithreaded version running with Geant 4.1.0 with Qt4
Comment 5 Olivier Delaune 2015-07-09 22:39:22 CEST
Prob lem still present in GEANT4 10.1.2. It works perfectly with Qt 4.8.6 and I get a segfault with Qt 5.4.0.
Is there a way to force GEANT4 to use Qt4 instead of Qt5 when both version are present on the system?
Comment 6 Laurent Garnier 2015-10-07 11:08:11 CEST
Hi, 

This bug only occurs when you issue a "/vis/open OGLxxx" command in a macro file loaded at startup. This should works, but on some plateforms (moslty Linux + Qt5), it crash.

== Two possible way to fix this ==

1) Do not run any .mac file at startup and load it after with /control/execute

2) Comment this line and recompile Geant4.

In : source/interfaces/basic/src/G4UIQt.cc

Line 724 : fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);

The side effect of 2) is that you have to clic on the tab viewer widget, and move your volume with mouse in order to activate the viewer.

Laurent
Comment 7 Laurent Garnier 2015-12-10 17:58:03 CET
Problem as been solved in geant4 10.2 (december 2015)
Comment 8 Laurent Garnier 2016-01-28 17:59:57 CET
*** Problem 1772 has been marked as a duplicate of this problem. ***