Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in libQt5Gui.so.5 when qview is compiled with -stdlib=libc++ #395

Closed
telans opened this issue Feb 19, 2021 · 14 comments
Closed

Segfault in libQt5Gui.so.5 when qview is compiled with -stdlib=libc++ #395

telans opened this issue Feb 19, 2021 · 14 comments
Labels
bug Something isn't working

Comments

@telans
Copy link

telans commented Feb 19, 2021

UPDATE: Fixed by using -stdlib=libstdc++ instead of -stdlib=libc++


Environment:

  • OS: Gentoo ~amd64
  • qView version: b662db3
  • Qt version: 5.15.2

clang -v:

clang version 12.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/12/bin
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
CFLAGS="-march=znver2 -O3 -glldb -pipe"
CXXFLAGS="-march=znver2 -O3 -glldb -pipe"

Information:
When qview is compiled with Clang the program fails to start with a segfault. Below is a backtrace of the segfault, not sure how useful it is. To me it looks like this might be a Qt issue though I haven't seen this issue in any other Qt programs.

The rest of Qt is also compiled with Clang. I will test and update whether or not building qtcore etc with GCC fixes the issue.

Using a different Clang version (i.e 11) has no effect.

Backtrace:

Process 291548 launched: '/usr/bin/qview' (x86_64)
Only C and default locale supported with the posix collation implementation
Only C and default locale supported with the posix collation implementation
Numeric mode unsupported in the posix collation implementation
libQt5Gui.so.5 was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 291548 stopped
* thread #1, name = 'qview', stop reason = signal SIGSEGV: invalid address (fault address: 0x14)
    frame #0: 0x00007ffff747cf00 libQt5Gui.so.5`QApplicationStateChangeEvent::applicationState(this=0x0000000000000000) const at qevent.cpp:5223:12 [opt]
   5220	*/
   5221	Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const
   5222	{
-> 5223	    return m_applicationState;
   5224	}
   5225	
   5226	/*!
(lldb) bt
* thread #1, name = 'qview', stop reason = signal SIGSEGV: invalid address (fault address: 0x14)
  * frame #0: 0x00007ffff747cf00 libQt5Gui.so.5`QApplicationStateChangeEvent::applicationState(this=0x0000000000000000) const at qevent.cpp:5223:12 [opt]
    frame #1: 0x00000000002abdf8 qview`QVApplication::event(this=0x00007fffffffdef0, event=0x00007fffffffdbc8) at qvapplication.cpp:97:25 [opt]
    frame #2: 0x00007ffff7ba3ad5 libQt5Widgets.so.5`QApplicationPrivate::notify_helper(this=<unavailable>, receiver=0x00007fffffffdef0, e=0x00007fffffffdbc8) at qapplication.cpp:3632:26 [opt]
    frame #3: 0x00007ffff7ba506f libQt5Widgets.so.5`QApplication::notify(this=<unavailable>, receiver=0x00007fffffffdef0, e=0x00007fffffffdbc8) at qapplication.cpp:0 [opt]
    frame #4: 0x00007ffff6f5bbe4 libQt5Core.so.5`QCoreApplication::notifyInternal2(receiver=0x00007fffffffdef0, event=<unavailable>) at qcoreapplication.cpp:1063:18 [opt]
    frame #5: 0x00007ffff7463cb5 libQt5Gui.so.5`QGuiApplicationPrivate::setApplicationState(state=<unavailable>, forcePropagate=<unavailable>) at qguiapplication.cpp:3757:5 [opt]
    frame #6: 0x00007ffff74636f4 libQt5Gui.so.5`QGuiApplicationPrivate::processActivatedEvent(e=0x0000000000548ba0) at qguiapplication.cpp:2498:9 [opt]
    frame #7: 0x00007ffff744645a libQt5Gui.so.5`QWindowSystemInterface::sendWindowSystemEvents(flags=<unavailable>) at qwindowsysteminterface.cpp:1169:13 [opt]
    frame #8: 0x00007ffff4fa9c1a libQt5XcbQpa.so.5`xcbSourceDispatch(source=<unavailable>, (null)=<unavailable>, (null)=<unavailable>)(void*), void*) at qxcbeventdispatcher.cpp:105:5 [opt]
    frame #9: 0x00007ffff5d26566 libglib-2.0.so.0`g_main_context_dispatch + 438
    frame #10: 0x00007ffff5d26ca9 libglib-2.0.so.0`___lldb_unnamed_symbol114$$libglib-2.0.so.0 + 985
    frame #11: 0x00007ffff5d26f7b libglib-2.0.so.0`g_main_context_iteration + 59
    frame #12: 0x00007ffff6fb8218 libQt5Core.so.5`QEventDispatcherGlib::processEvents(this=0x000000000031ac80, flags=<unavailable>) at qeventdispatcher_glib.cpp:423:19 [opt]
    frame #13: 0x00007ffff6f579a7 libQt5Core.so.5`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QEventLoop::processEvents(this=0x00007fffffffde80, flags=(i = 36)) at qeventloop.cpp:139:55 [opt]
    frame #14: 0x00007ffff6f57988 libQt5Core.so.5`QEventLoop::exec(this=0x00007fffffffde80, flags=<unavailable>) at qeventloop.cpp:232 [opt]
    frame #15: 0x00007ffff6f5c261 libQt5Core.so.5`QCoreApplication::exec() at qcoreapplication.cpp:1371:32 [opt]
    frame #16: 0x0000000000292e0b qview`main(argc=1, argv=<unavailable>) at main.cpp:24:12 [opt]
    frame #17: 0x00007ffff677afba libc.so.6`__libc_start_main + 234
    frame #18: 0x0000000000292a8a qview`_start + 42
@telans telans added the bug Something isn't working label Feb 19, 2021
@jurplel
Copy link
Owner

jurplel commented Feb 19, 2021

Are you using wayland?

@telans
Copy link
Author

telans commented Feb 19, 2021

No, X11 (i3)

@telans
Copy link
Author

telans commented Feb 19, 2021

Same result when compiling Qt with GCC 10.2.0. Are you able to verify that compiling qview with Clang results in a segfault?

@jurplel
Copy link
Owner

jurplel commented Feb 19, 2021

Just tried with clang and there was no segfault. Maybe it's because of -O3? I am seeing in your backtrace: libQt5Gui.so.5 was compiled with optimization - stepping may behave oddly; variables may not be available.

@telans
Copy link
Author

telans commented Feb 19, 2021

That message is present at all -O levels I beleive. Regardless, no change with -O2. I imagine this is something I'll end up reporting to the Qt folks

@jurplel
Copy link
Owner

jurplel commented Feb 19, 2021

I am on arch linux with clang 11.0.1--maybe it's clang 12?

@jurplel
Copy link
Owner

jurplel commented Feb 19, 2021

Oh, I see you already mentioned that. Nevermind.

@novomesk
Copy link

novomesk commented Mar 1, 2021

@telans This happens also with media-gfx/qview-4.0::guru package?

@telans
Copy link
Author

telans commented Mar 1, 2021

Yes. No change after multiple emerge -e @world's. I got someone who is also systemwide clang to test and they have no issues. It should probably be mentioned that I have global issues with Clang + LTO and Qt packages, too. I suspect it has something to do with -march=znver2 but I have yet to rebuild my system to test it.

@telans
Copy link
Author

telans commented Mar 3, 2021

@novomesk I've narrowed this down to the flags -rtlib=compiler-rt -libunwind=libunwind which are on by default for me because of sys-devel/clang[default-compiler-rt] and sys-libs/llvm-libunwind. Specifying -rtlib=libgcc -libunwind=libgcc fixes the issue. Do you mind confirming?

@telans telans changed the title Segfault in libQt5Gui.so.5 when qview is compiled with Clang Segfault in libQt5Gui.so.5 when qview is compiled with -rtlib=compiler-rt Mar 3, 2021
@novomesk
Copy link

novomesk commented Mar 3, 2021

@telans So far I was unable to reproduce problem. I tried clang++ --rtlib=compiler-rt -flto but I don't have default-compiler-rt flag enabled.

I have sys-libs/libunwind installed but not sys-libs/llvm-libunwind

@telans
Copy link
Author

telans commented Mar 3, 2021

@jurplel I filed a bug with Qt and someone there responded with something that may be a fix: https://bugreports.qt.io/browse/QTBUG-91510

I'm not sure why you can't reproduce it novomesk, maybe because I use -stdlib=libc++ too?

Update: In fact it seems to be only libc++ causing it, sorry for the confusion

@telans telans changed the title Segfault in libQt5Gui.so.5 when qview is compiled with -rtlib=compiler-rt Segfault in libQt5Gui.so.5 when qview is compiled with -stdlib=libc++ Mar 3, 2021
@telans
Copy link
Author

telans commented Mar 5, 2021

@jurplel using static_cast at

auto *stateEvent = dynamic_cast<QApplicationStateChangeEvent*>(event);
does fix the issue but I'm not sure what ramifications (if any) it has.

@jurplel jurplel closed this as completed in ff28423 Mar 5, 2021
@jurplel
Copy link
Owner

jurplel commented Mar 5, 2021

I just got schooled, I suppose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants