Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 754021 - net-analyzer/wireshark-3.4.0[lto]: crash at start
Summary: net-analyzer/wireshark-3.4.0[lto]: crash at start
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Sam James
URL: https://gitlab.com/wireshark/wireshar...
Whiteboard:
Keywords:
Depends on:
Blocks: lto 915000
  Show dependency tree
 
Reported: 2020-11-11 12:34 UTC by Andrei Slavoiu
Modified: 2023-10-01 10:15 UTC (History)
15 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Slavoiu 2020-11-11 12:34:59 UTC
Tested with USE=-lto and it works fine, but with USE=+lto I get:

Thread 1 "wireshark" received signal SIGSEGV, Segmentation fault.
doActivate<false> (sender=0x0, signal_index=9, argv=argv@entry=0x7fffffffd000) at /usr/src/debug/dev-qt/qtcore-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/corelib/kernel/qobject.cpp:3768
3768        QObjectPrivate *sp = QObjectPrivate::get(sender);
(gdb) bt
#0  doActivate<false> (sender=0x0, signal_index=9, argv=argv@entry=0x7fffffffd000) at /usr/src/debug/dev-qt/qtcore-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/corelib/kernel/qobject.cpp:3768
#1  0x00007fffefd38d68 in QMetaObject::activate (sender=<optimized out>, m=m@entry=0x7ffff057cfa0 <QGuiApplication::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffffd000)
    at /usr/src/debug/dev-qt/qtcore-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/corelib/kernel/qobject.cpp:3946
#2  0x00007ffff00ea0f2 in QGuiApplication::screenAdded (this=<optimized out>, _t1=<optimized out>, _t1@entry=0x555555d632e0) at .moc/moc_qguiapplication.cpp:389
#3  0x00007ffff00da26c in QWindowSystemInterface::handleScreenAdded (ps=ps@entry=0x555555d5be60, isPrimary=<optimized out>) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/gui/kernel/qwindowsysteminterface.cpp:827
#4  0x00007fffeb637fe0 in QXcbConnection::initializeScreens (this=this@entry=0x555555d2dff0) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/plugins/platforms/xcb/qxcbconnection_screens.cpp:411
#5  0x00007fffeb612d40 in QXcbConnection::QXcbConnection (this=0x555555d2dff0, nativeInterface=<optimized out>, canGrabServer=<optimized out>, defaultVisualId=<optimized out>, displayName=<optimized out>)
    at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/plugins/platforms/xcb/qxcbconnection.cpp:103
#6  0x00007fffeb615b72 in QXcbIntegration::QXcbIntegration (this=0x555555d2df00, parameters=..., argc=@0x7fffffffd7cc: 1, argv=<optimized out>) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/plugins/platforms/xcb/qxcbintegration.cpp:199
#7  0x00007ffff7fc84b8 in QXcbIntegrationPlugin::create (this=<optimized out>, system=..., argv=0x7fffffffdb08, argc=@0x7fffffffd7cc: 1, parameters=...) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/plugins/platforms/xcb/qxcbmain.cpp:56
#8  QXcbIntegrationPlugin::create (this=<optimized out>, system=..., parameters=..., argc=@0x7fffffffd7cc: 1, argv=0x7fffffffdb08) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/plugins/platforms/xcb/qxcbmain.cpp:53
#9  0x00007ffff00e2f9b in QPlatformIntegrationFactory::create (platform=..., paramList=..., argc=@0x7fffffffd7cc: 1, argv=<optimized out>, argv@entry=0x7fffffffdb08, platformPluginPath=...) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/gui/kernel/qplatformintegrationfactory.cpp:71
#10 0x00007ffff00ed9cd in init_platform (argv=<optimized out>, argc=@0x7fffffffd7cc: 1, platformThemeName=..., platformPluginPath=..., pluginNamesWithArguments=...) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/gui/kernel/qguiapplication.cpp:1223
#11 QGuiApplicationPrivate::createPlatformIntegration (this=0x555555d1fee0) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/gui/kernel/qguiapplication.cpp:1481
#12 0x00007ffff00ef198 in QGuiApplicationPrivate::createEventDispatcher (this=<optimized out>) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/gui/kernel/qguiapplication.cpp:1498
#13 0x00007fffefd156b6 in QCoreApplicationPrivate::init (this=this@entry=0x555555d1fee0) at /usr/src/debug/dev-qt/qtcore-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/corelib/kernel/qcoreapplication.cpp:834
#14 0x00007ffff00f1ad4 in QGuiApplicationPrivate::init (this=this@entry=0x555555d1fee0) at /usr/src/debug/dev-qt/qtgui-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/gui/kernel/qguiapplication.cpp:1527
#15 0x00007ffff0baedf9 in QApplicationPrivate::init (this=0x555555d1fee0) at /usr/src/debug/dev-qt/qtwidgets-5.15.1/qtbase-everywhere-src-5.15.1/src/widgets/kernel/qapplication.cpp:513
#16 0x0000555555853b3e in WiresharkApplication::WiresharkApplication (this=<optimized out>, argc=<optimized out>, argv=<optimized out>, this=<optimized out>, argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/net-analyzer/wireshark-3.4.0/wireshark-3.4.0/ui/qt/wireshark_application.cpp:616
#17 0x00005555556594d1 in main (argc=<optimized out>, qt_argv=0x7fffffffdb08) at /usr/src/debug/net-analyzer/wireshark-3.4.0/wireshark-3.4.0/ui/qt/main.cpp:600


Reproducible: Always




Portage 3.0.9 (python 3.7.9-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-10.2.0, glibc-2.32-r2, 5.9.1-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.9.1-gentoo-x86_64-AMD_Ryzen_7_2700_Eight-Core_Processor-with-gentoo-2.7
KiB Mem:    57406060 total,    780024 free
KiB Swap:  134217724 total,  87240648 free
Timestamp of repository gentoo: Wed, 11 Nov 2020 12:15:01 +0000
Head commit of repository gentoo: e47c9f3f3402650d0cfcded164c7db248e33d94c
Head commit of repository gridcoin: f40c860bd0dcc9aeb82b9f24c32656497f4c86f4

Head commit of repository steam-overlay: 32203d28a724a74a1fa14720129f95b97a90efcd

sh bash 5.0_p18
ld GNU ld (Gentoo 2.35.1 p1) 2.35.1
ccache version 4.0 [enabled]
app-shells/bash:          5.0_p18::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.30.3-r1::gentoo
dev-lang/python:          2.7.18-r4::gentoo, 3.7.9::gentoo, 3.8.6::gentoo, 3.9.0::gentoo
dev-util/ccache:          4.0::gentoo
dev-util/cmake:           3.18.4::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.2::gentoo
sys-devel/binutils:       2.35.1::gentoo
sys-devel/gcc:            10.2.0-r3::gentoo
sys-devel/gcc-config:     2.3.2::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.9::gentoo (virtual/os-headers)
sys-libs/glibc:           2.32-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.europe.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes

local
    location: /usr/local/portage
    masters: gentoo
    priority: 0

gridcoin
    location: /usr/local/portage/gridcoin-overlay
    sync-type: git
    sync-uri: https://github.com/nethershaw/gridcoin.git
    masters: gentoo
    priority: 50

steam-overlay
    location: /usr/local/portage/steam-overlay
    sync-type: git
    sync-uri: https://github.com/anyc/steam-overlay.git
    masters: gentoo
    priority: 50

Installed sets: @games, @kde
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA google-chrome AdobeFlash-11.x AMD-GPU-PRO-EULA RAR ms-teams-pre"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -ggdb3 -O2 -pipe -fdiagnostics-color"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -ggdb3 -O2 -pipe -fdiagnostics-color"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg ccache cgroup clean-logs compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles installsources ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirrors.evowise.com/gentoo/ http://ftp.romnet.org/gentoo/ http://distfiles.gentoo.org"
LANG="ro_RO.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,now"
LINGUAS="ro ro_RO en eo"
MAKEOPTS="-j8 -l16"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="7zip X a52 aac aacplus aalib acl acpi activities alsa amd64 amr autoipd avahi bash-completion berkdb branding btrfs bzip2 cacert cairo caps cdda cdr cgroups clang cli client cmake cpufreq_bench crypt cups curl cxx dbus debug-frame declarative demos designer discover dolphin dos dot dri dts dvd dvdr egl elogind emboss emoji encode equalizer evdev exif extra fbcondecor feedback ffmpeg firmware flac flatpak fortran gcrypt gd gdbm gif git gles gles2 glslang gmp gnutls google gpg gpm grub gssapi gui haptic highlight htmlthumbs http http2 hunspell hwloc ibus iconv icu idn io-uring ipv6 jadetex jpeg jpeg2k jumbo-build kde kerberos kipi kwallet lcms libcaca libdrm libglvnd libidn2 libkms libplacebo libtirpc libudev lm-sensors lm_sensors lto lzma mad mdnsresponder-compat metalink midi mikmod mng mod mp3 mp4 mpeg mtp multilib multimedia ncat ncurses nettle networkmanager nls nptl ntp numpy nvme offensive office offload ogg openal opencl openconnect opencv opengl openmp openssl opus pam pango pcap pch pcntl pcre pdf pgo phonon pim pkcs7 plasma plotutils plymouth pm-utils png policykit postproc ppds pulseaudio qml qrcode qt5 qtmedia rar readline rtmp samba sasl scanner schroedinger screencast script scripttools sdk sdl sdl-image sdl2 seccomp semantic-desktop sms sndfile sound source-highlight speech speex spell spice split-usr sqlite ssl startup-notification streaming svg symlink system-bootstrap system-libs system-snappy systemtap taglib tcpd telemetry textures theora threads tiff timidity tinfo tracepath truetype udev udisks uefi unicode unwind upnp upower usb user-session utils vaapi valgrind vdpau videos virgl virt-network vlc voice vorbis vpx vulkan vulkan-overlay wayland webengine webp widgets winbind x264 x265 xattr xcb xml xrandr xv xvfb xvid xz yahoo zeroconf zip zlib zstd" ABI_X86="64 32" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64 pc" INPUT_DEVICES="evdev joystick libinput roccat_kovaplus" KERNEL="linux" L10N="ro en eo" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="AMDGPU" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7" QEMU_SOFTMMU_TARGETS="aarch64 x86_64" QEMU_USER_TARGETS="aarch64 aarch64_be" RUBY_TARGETS="ruby25 ruby26" SANE_BACKENDS="pixma" USERLAND="GNU" VIDEO_CARDS="amdgpu radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

net-analyzer/wireshark-3.4.0::gentoo was built with the following:
USE="capinfos captype dftest dumpcap editcap filecaps http2 kerberos mergecap minizip netlink opus pcap plugins qt5 randpkt randpktdump reordercap sharkd ssl text2pcap tshark udpdump zlib zstd -androiddump -bcg729 -brotli -ciscodump -doc -dpauxmon -ilbc -libxml2 -lto -lua -lz4 -maxminddb -plugin-ifdemo -sbc -sdjournal (-selinux) -smi -snappy -spandsp -sshdump -test -tfshark" ABI_X86="(64)"
CXXFLAGS="-march=native -ggdb3 -O2 -pipe -fdiagnostics-color -fPIC -DPIC"
FEATURES="distlocks qa-unresolved-soname-deps xattr multilib-strict splitdebug sfperms ebuild-locks ipc-sandbox preserve-libs buildpkg fixlafiles usersandbox pid-sandbox binpkg-logs network-sandbox binpkg-docompress userpriv unknown-features-warn sandbox unmerge-orphans parallel-fetch unmerge-logs parallel-install binpkg-dostrip userfetch installsources compressdebug ccache news assume-digests config-protect-if-modified cgroup strict merge-sync protect-owned clean-logs usersync"
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-11 18:53:51 UTC Comment hidden (obsolete)
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-11 18:58:28 UTC
Dying when passing things into Qt is weird: https://gitlab.com/wireshark/wireshark/-/blob/release-3.4/ui/qt/wireshark_application.cpp#L616.

I suggest you report this upstream because it's unlikely to be related to how we package Wireshark in Gentoo.

Did you use any command like arguments?
Comment 3 Arusekk 2020-11-25 07:29:16 UTC
Confirmed. Any invocation of wireshark that instantiates QCoreApplication is crashing (e.g. wireshark crashes, but wireshark --help does not).

Crash happens because wireshark somehow defines QCoreApplication::self (a static member) multiple times:
gdb -nx -ex 'b /usr/src/debug/dev-qt/qtcore-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/corelib/kernel/qcoreapplication.cpp:773' -ex r wireshark
(gdb) p &QCoreApplication::self
$1 = (QCoreApplication **) 0x555555cc8020 <QCoreApplication::self>
(gdb) disassemble /s $rip,+8
Dump of assembler code from 0x7fffefda9b73 to 0x7fffefda9b7b:
/usr/src/debug/dev-qt/qtcore-5.15.1-r1/qtbase-everywhere-src-5.15.1/src/corelib/kernel/qcoreapplication.cpp:
772         Q_ASSERT_X(!QCoreApplication::self, "QCoreApplication", "there should be only one application object");
773         QCoreApplication::self = q;
=> 0x00007fffefda9b73 <_ZN23QCoreApplicationPrivate4initEv+51>: lea    0x2b7b2e(%rip),%rax        # 0x7ffff00616a8
   0x00007fffefda9b7a <_ZN23QCoreApplicationPrivate4initEv+58>: mov    %rbx,(%rax)
End of assembler dump.

So later on QCoreApplication::instance() 's this is a null pointer, resulting in the crash.
Comment 4 David Korth 2020-12-04 01:40:57 UTC
I'm seeing the exact same crash with =app-admin/keepassxc-2.6.2. (with qt-5.15.2)

Stacktrace is effectively the same as the posted trace from wireshark.

Disabling LTO on both fixes both.
Comment 5 Andrew Udvare 2020-12-24 03:33:58 UTC
I am getting the same crash with Wireshark 3.4.2.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-12-24 21:12:39 UTC
(In reply to Andrew Udvare from comment #5)
> I am getting the same crash with Wireshark 3.4.2.

Please report the issue and link it here as I can’t reproduce it right now.
Comment 7 jannis 2020-12-25 22:09:06 UTC
Thank you so much for pointing out that it works with USE="-lto". I was desperate why wireshark works on my desktop machine but won't start on my laptop!
Comment 8 Arusekk 2021-01-07 16:54:06 UTC
As per the keepassxc comment, the real problem might be that dev-qt/qtcore is not prepared to handle its library variables being replaced by the executable. Because they are.

This is reproduced if the final executable (wireshark/keepassxc) uses all of -flto and -fPIE linker flags, because replacing -fPIE with -fPIC uses the exported symbol from the library.

So maybe qtcore -flto is linked with -fPIE instead of -fPIC too? (while being a library, so this would be very wrong)
Comment 9 Gary E. Miller 2021-01-30 23:11:55 UTC
I can confirm this builds a working wireshark on gentoo unstable:

USE=-lto emerge =net-analyzer/wireshark-3.4.3

Thanks for the tip.
Comment 10 Maciej S. Szmigiero 2021-02-13 17:32:22 UTC
(In reply to Gary E. Miller from comment #9)
> I can confirm this builds a working wireshark on gentoo unstable:
> 
> USE=-lto emerge =net-analyzer/wireshark-3.4.3

Can confirm this, too.
And that I get a crash in doActivate() with USE=lto.
Comment 11 Arusekk 2021-03-09 14:19:46 UTC
(CC from upstream comment)

This issue is not specific to Wireshark, it can be triggered by the following simple code:

#include <QApplication>
#include <QDebug>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    qDebug() << qApp->styleSheet();
}

(note that even bugs aside, `app.styleSheet()` would be more appropriate than `qApp->styleSheet()`)

and a sample qmake `.pro` file (for brevity, CMakeLists.txt would be way longer, but this shows the absolute minimal setup needed, and should be readable anyway)

QT += gui widgets
SOURCES += qtlto.cc
QMAKE_CXXFLAGS += -flto
QMAKE_LFLAGS += -pie -fPIE

Removing any of the flags above results in a working executable (printing "").

so this might be a linker bug (lto1 bug) here, a compiler bug in compiling Qt (cc1plus/lto1 bug), or Qt compilation flags misconfiguration (Gentoo bug).
Comment 12 Sergei Trofimovich (RETIRED) gentoo-dev 2021-04-09 22:19:47 UTC
(In reply to Arusekk from comment #11)
> (CC from upstream comment)
> 
> This issue is not specific to Wireshark, it can be triggered by the
> following simple code:
> 
> #include <QApplication>
> #include <QDebug>
> 
> int main(int argc, char **argv)
> {
>     QApplication app(argc, argv);
>     qDebug() << qApp->styleSheet();
> }
> 
> (note that even bugs aside, `app.styleSheet()` would be more appropriate
> than `qApp->styleSheet()`)
> 
> and a sample qmake `.pro` file (for brevity, CMakeLists.txt would be way
> longer, but this shows the absolute minimal setup needed, and should be
> readable anyway)
> 
> QT += gui widgets
> SOURCES += qtlto.cc
> QMAKE_CXXFLAGS += -flto
> QMAKE_LFLAGS += -pie -fPIE
> 
> Removing any of the flags above results in a working executable (printing
> "").
> 
> so this might be a linker bug (lto1 bug) here, a compiler bug in compiling
> Qt (cc1plus/lto1 bug), or Qt compilation flags misconfiguration (Gentoo bug).

This project generates equivalent of:
  $ g++ -c -flto -fPIC qtlto.cc
  $ g++     -pie -fPIE qtlto.o -o qtlto

Note that lto merges all the flags from all the translation units to a single set as much as it can. I think -fPIC gets overridden by -fPIE based on documented rule from 'man gcc':

   -flto[=n]
       ...
           The following options -fPIC, -fpic, -fpie and -fPIE are combined based on the following scheme:
                   B<-fPIC> + B<-fpic> = B<-fpic>
                   B<-fPIC> + B<-fno-pic> = B<-fno-pic>
                   B<-fpic/-fPIC> + (no option) = (no option)
                   B<-fPIC> + B<-fPIE> = B<-fPIE>
                   B<-fpic> + B<-fPIE> = B<-fpie>
                   B<-fPIC/-fpic> + B<-fpie> = B<-fpie>

Which combines towards stricter requirements assuming bytecode already applied some optimisations based on preprocessor values.

I see that Qt normally disallows anything to be built without -fPIC (at least in Gentoo):

    /usr/include/qt5/QtCore/qglobal.h:1286:4: error: #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC (and not with -fPIE)."

I think wireshark's CMakeLists.txt imposes -fPIE and effectively throws away -fPIC at:
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Gentoo's toolchain already uses -fPIE where appropriate without explicit flags. I'd say wireshark would have to avoid -fPIE.

I think ideal state for wireshark would be to do -fPIC + -pie.
Comment 13 Larry the Git Cow gentoo-dev 2021-04-09 22:51:54 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=22aba2f719c9f40e1d9285bba7173091b2b77125

commit 22aba2f719c9f40e1d9285bba7173091b2b77125
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-04-09 22:44:07 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-04-09 22:51:16 +0000

    profiles/base: mask net-analyzer/wireshark[lto] for now
    
    Crashes at runtime.
    
    Bug: https://bugs.gentoo.org/754021
    Signed-off-by: Sam James <sam@gentoo.org>

 profiles/base/package.use.mask | 7 +++++++
 1 file changed, 7 insertions(+)
Comment 14 Adrien Dessemond 2023-05-30 14:05:04 UTC
Reproducible with Wireshark 4.0.0 (GCC 13.1) + dev-qt/qtcore-5.15.0.

Seems there is no bug report on the subject for dev-qt/qtcore.

Disabling LTO for Wireshark does not trigger the segfault.
Comment 15 Larry the Git Cow gentoo-dev 2023-06-17 16:09:48 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a2494b77d21f70b6e1fef71496e23740b550116e

commit a2494b77d21f70b6e1fef71496e23740b550116e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-06-17 16:09:03 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-06-17 16:09:03 +0000

    net-analyzer/wireshark: add missing filter-lto for USE=-lto
    
    Note that USE=lto is masked right now too.
    
    Bug: https://bugs.gentoo.org/754021
    Signed-off-by: Sam James <sam@gentoo.org>

 net-analyzer/wireshark/wireshark-3.6.13.ebuild | 2 ++
 net-analyzer/wireshark/wireshark-3.6.14.ebuild | 2 ++
 net-analyzer/wireshark/wireshark-4.0.5.ebuild  | 2 ++
 net-analyzer/wireshark/wireshark-4.0.6.ebuild  | 2 ++
 net-analyzer/wireshark/wireshark-9999.ebuild   | 2 ++
 5 files changed, 10 insertions(+)