Lazarus

Programming => Widgetset => QT => Topic started by: alanphys on January 10, 2018, 01:38:10 pm

Title: SIGSEGV on exiting application under QT5.6
Post by: alanphys on January 10, 2018, 01:38:10 pm
Hi

I've recently installed Fedora 26 with KDE 5 and QT 5.6 on a new system. I managed to build and install libQt5Pas.so as per the wiki and rebuild Lazarus for QT5. My applications compile and run in the debugger correctly. The only thing is that when I exit my application while running it in Lazarus I get a SIGSEGV error and Lazarus remains in debugging mode and I have to stop the application manually. This occurs whether I have debugging enabled (-gw) or not. If I run the applications outside Lazarus they appear to exit cleanly. The same applications exited properly on my previous Fedora 24 with KDE4 and Windows systems.

This issue is trivial, but annoying and I don't know enough about Lazarus to fault find. Any pointers or tips will be welcome.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: JuhaManninen on January 10, 2018, 02:45:23 pm
I get the same SIGSEGV also with QT4 bindings. I tried to find the reason but could not.
See thread "How is EntryInformation.OS.haltproc assigned?" in FPC-Pascal mailing list:
 http://readlist.com/lists/lists.freepascal.org/fpc-pascal/8/42964.html
Zeljko (LCL-QT maintainer) gets it only with QT5.
How to fix it? Nasty bug.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: alanphys on January 10, 2018, 03:01:58 pm
I didn't have this problem with the QT 4 bindings, but I had to downgrade the debugger (gdb) due to a host of other problems. I'll track down the previous debugger version I used and see if I still have the problem.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 11, 2018, 12:10:25 pm
Problem is that usually with Qt5 I cannot get AV on application terminate when running under gdb. It just happens after closing app and gdb cannot catch that part. Didn't find any way to even have an idea about problem. On the other hand, when using Qt5 under win32, never had such AV on app termination.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 23, 2018, 11:51:20 pm
Hi zeljko

I met this problem in slackware-current/qt5, from 5.7 to 5.9.3.
after any program exit, include lazarus ide, there will be AV and some callstack dumped.
1.8.0 and trunk(r59141) is the same.

following is something maybe helpful
----------------------------------BEGIN----------------------------------------------------------
(gdb) r
Starting program: /root/work/devel/2/nxdlinux/mgr/nlmgr
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
[New Thread 0x7fffeab8a700 (LWP 1847)]
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
[New Thread 0x7fffe0c61700 (LWP 1848)]
[New Thread 0x7fffdbfff700 (LWP 1849)]
[New Thread 0x7fffd9a88700 (LWP 1852)]

Thread 1 "nlmgr" received signal SIGSEGV, Segmentation fault.
0x00007ffff6eca979 in _dl_catch_error () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff6eca979 in _dl_catch_error () at /lib64/libc.so.6
#1  0x00007ffff79b45c5 in _dlerror_run () at /lib64/libdl.so.2
#2  0x00007ffff79b3fff in dlclose () at /lib64/libdl.so.2
#3  0x00007ffff5150e03 in  () at /usr/lib64/libQt5Core.so.5
#4  0x00007ffff514ae6d in  () at /usr/lib64/libQt5Core.so.5
#5  0x00007ffff513bd92 in  () at /usr/lib64/libQt5Core.so.5
#6  0x00007ffff513bed9 in  () at /usr/lib64/libQt5Core.so.5
#7  0x00007ffff518a1a3 in QObject::~QObject() () at /usr/lib64/libQt5Core.so.5
#8  0x00007ffff5a96d49 in  () at /usr/lib64/libQt5Gui.so.5
#9  0x00007ffff6daddd8 in __run_exit_handlers () at /lib64/libc.so.6
#10 0x00007ffff6dade2a in  () at /lib64/libc.so.6
#11 0x00007ffff6d94031 in __libc_start_main () at /lib64/libc.so.6
#12 0x0000000000000000 in  ()
-----------------------------------END--------------------------------------------------------------

I'm not sure to report an issue, you may have a look first.

If you need more details or some test, just give me a message.

Thanks you and lazarus team.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 24, 2018, 12:52:23 pm
Last night I've got understandable stack dump too...with Qt-5.9.2.No matter if it's simple app with one form or huge project - stack dump is always same, and it happens in QObject destructor, so dont know if it's something about our C bindings or Qt bug.
#0  0x00007ffff6cc016c in _dl_catch_error () from /lib64/libc.so.6
#1  0x00007ffff79b46a5 in _dlerror_run () from /lib64/libdl.so.2
#2  0x00007ffff79b401f in dlclose () from /lib64/libdl.so.2
#3  0x00007ffff5c621b3 in QLibraryPrivate::unload_sys() () from /lib64/libQt5Core.so.5
#4  0x00007ffff5c5de3d in QLibraryPrivate::unload(QLibraryPrivate::UnloadFlag) () from /lib64/libQt5Core.so.5
#5  0x00007ffff5c4f732 in QFactoryLoaderPrivate::~QFactoryLoaderPrivate() () from /lib64/libQt5Core.so.5
#6  0x00007ffff5c4f879 in QFactoryLoaderPrivate::~QFactoryLoaderPrivate() () from /lib64/libQt5Core.so.5
#7  0x00007ffff5c9643a in QObject::~QObject() () from /lib64/libQt5Core.so.5
#8  0x00007ffff5c4eb4b in QFactoryLoader::~QFactoryLoader() () from /lib64/libQt5Core.so.5
#9  0x00007ffff6199749 in (anonymous namespace)::Q_QGS_loader::innerFunction()::Holder::~Holder () from /lib64/libQt5Gui.so.5
#10 0x00007ffff6ba5fc8 in __run_exit_handlers () from /lib64/libc.so.6
#11 0x00007ffff6ba601a in exit () from /lib64/libc.so.6
#12 0x00007ffff6b8b891 in __libc_start_main () from /lib64/libc.so.6
#13 0x0000000000000000 in ?? ()
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 24, 2018, 12:56:41 pm
Related issues, IMO, this is probably glibc bug, see possible workaround at git link.
https://bugreports.qt.io/browse/QTBUG-50098
https://bugreports.qt.io/browse/QTBUG-56470
https://git.merproject.org/mer-core/qtbase/commit/0da54716647780df0e1b54b03c3e8e007b78bb8a
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 24, 2018, 07:21:53 pm
but....
on the same time, it's all ok in Arch...

I did not compare glibc different between them, only confirmed they are all version 2.26
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 25, 2018, 01:48:35 pm
If that error doesn't trigger under arch then it's obvious that we cannot fix it inside lcl code. So, that could be glibc bug, but also Qt bug which is fixed by distro maintainer (if we are about same Qt versions on different distros).
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 25, 2018, 02:29:38 pm
Ok, I will do more test and may report a bug to slackware maintainer
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 25, 2018, 09:16:50 pm
It's not Qt5 only, I have error when closing Qt4 app on Fedora 26.
Last night I've upgraded from Fedora 25 (Qt-5.7.1, Qt-4.8.7) to Fedora 26 (Qt-5.9.2, Qt-4.8.7) and now have segfaults when app is closed.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 25, 2018, 11:17:48 pm
I do a test on slackware x86_64 14.2 with QT 5.7.1 today, it's good. and QT4 never met this issue on my systems(include slackware and arch)
already posted at linuxquestions.net, but no response for now...

BTW I was saw printer related strings in backtrace once and I haven't print service installed.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 27, 2018, 10:53:28 am
What exact printer related strings ? Can you paste console output here ?
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 27, 2018, 11:58:10 am
Seem that adding QCoreApplication_destroy(QCoreApplication_instance()) in TQtWidgetSet.Destroy (just before inherited Destroy) fixes segfault with Qt4 under newer distros, but Qt5 definitelly have other problem , segfault comes after QCoreApplication is destroyed
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 27, 2018, 02:57:51 pm
The attachement is full backtrace of all exceptions.

In second one's bt, it say

(gdb) bt
#0  0x00007ffff6eca979 in _dl_catch_error () at /lib64/libc.so.6
#1  0x00007ffff79b45c5 in _dlerror_run () at /lib64/libdl.so.2
#2  0x00007ffff79b3fff in dlclose () at /lib64/libdl.so.2
#3  0x00007ffff5150e03 in  () at /usr/lib64/libQt5Core.so.5
#4  0x00007ffff514ae6d in  () at /usr/lib64/libQt5Core.so.5
#5  0x00007ffff513bd92 in  () at /usr/lib64/libQt5Core.so.5
#6  0x00007ffff513bed9 in  () at /usr/lib64/libQt5Core.so.5
#7  0x00007ffff518a1a3 in QObject::~QObject() () at /usr/lib64/libQt5Core.so.5
#8  0x00007ffff6b3b3d9 in  () at /usr/lib64/libQt5PrintSupport.so.5
....


I already installed cups package, but not run cups daemon.
may not so related to printer, IMO.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 27, 2018, 07:28:34 pm
That's same thing:
#0  0x00007ffff6eca979 in _dl_catch_error () at /lib64/libc.so.6
#1  0x00007ffff79b45c5 in _dlerror_run () at /lib64/libdl.so.2
#2  0x00007ffff79b3fff in dlclose () at /lib64/libdl.so.2

Crash comes from glibc (or from wrong Qt implementation when unloading library)
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 28, 2018, 03:52:15 am
http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html
downloaded demo from here, change qt4 -> qt5, 2 program compile passed.
SIGSEGV is the same...
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 29, 2018, 06:22:53 am
tested at slackware 14.2 x86-64, glibc-2.23
upgraded qt5 5.9.3 from here:
https://slackware.pkgs.org/14.2/slackel-x86_64/qt5-5.9.3-x86_64-1dj.txz.html

it's ok, so looks like this issue is related to glibc for 90%...
but arch is running with glibc 2.26 also and it's ok there.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 29, 2018, 11:44:35 am
Probably arch uses some custom glibc patch, or different could be distro combination of glibc and gcc. Really don't know. Maybe one must write pure simple Qt c++ app to see if crash occurs.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 29, 2018, 04:08:50 pm
tested ok on ubuntu and arch, detail version info:

ubuntu 17.10
   qt 5.9.1
   glibc 2.26
   gcc 7.2.0

arch
   qt 5.10.0
   glibc 2.26
   gcc 7.3.0


will try to rebuild glibc and test.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on January 29, 2018, 09:15:02 pm
ok, I give up, after build glibc 3 times, I totally no idea how to do now.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: zeljko on January 30, 2018, 09:39:12 am
Fedora 26 uses glibc 2.25 and there we have problem. glibc 2.23, 2.24 works fine on fedoras.
If you don't have problems with 2.26 then it's obvious where bug is.
Title: Re: SIGSEGV on exiting application under QT5.6
Post by: baldzhang on February 02, 2018, 04:16:53 pm
build and upgrade glibc 2.27, it's ok now