Summary: | net-analyzer/wireshark-3.4.0[lto]: crash at start | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Andrei Slavoiu <ansla80> |
Component: | Current packages | Assignee: | Sam James <sam> |
Status: | UNCONFIRMED --- | ||
Severity: | normal | CC: | admnd, arek_koz, bman, eschwartz93, esigra, flexx, gem, gentoo, hanno, kripton, mads, mail, qt, sam, toolchain, wgh |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://gitlab.com/wireshark/wireshark/-/issues/17040 | ||
See Also: | https://gitlab.com/wireshark/wireshark/-/issues/19822 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 618550, 915000 |
Description
Andrei Slavoiu
2020-11-11 12:34:59 UTC
gdb will be helpful here (see https://wiki.gentoo.org/wiki/Debugging, we want debugging symbols on Wireshark, probably qtcore, glibc can be useful too) but I anticipate this being an upstream bug. It's unlikely to be specific to how we package Wireshark in Gentoo. 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? 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. 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. I am getting the same crash with Wireshark 3.4.2. (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. 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! 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) I can confirm this builds a working wireshark on gentoo unstable: USE=-lto emerge =net-analyzer/wireshark-3.4.3 Thanks for the tip. (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. (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). (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. 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(+) 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. 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(+) FAILED: run/plugins/4.3/epan/wimax.so : && /usr/bin/x86_64-pc-linux-gnu-gcc -fPIC -fvisibility=hidden -Wall -Wextra -Wpointer-arith -Wformat-security -fno-strict-overflow -fexcess-precision=fast -Wvla -Wattributes -Wpragmas -Wredundant-decls -Wunreachable-code -Wlogical-op -Wno-error=stringop-overflow= -Wno-error=deprecated-declarations -Wframe-larger-than=32768 -Wno-format-truncation -fdiagnostics-color=always -Wshadow -Wold-style-definition -Wstrict-prototypes -Wno-pointer-sign -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -fmacro-prefix-map="/var/tmp/portage/net-analyzer/wireshark-9999/work/wireshark-9999/"= -fmacro-prefix-map="/var/tmp/portage/net-analyzer/wireshark-9999/work/wireshark-9999_build/"= -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,--as-needed -shared -o run/plugins/4.3/epan/wimax.so plugins/epan/wimax/CMakeFiles/wimax.dir/plugin.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/packet-m2m.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/packet-wmx.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_ffb_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_fch_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_pdu_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_cdma_code_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_hack_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_phy_attributes_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/mac_hd_generic_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/mac_hd_type1_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/mac_hd_type2_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/mac_mgmt_msg_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_dcd.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_ucd.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_dlmap.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_ulmap.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_rng_req.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_rng_rsp.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_reg_req.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_reg_rsp.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_dreg.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_dsa.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_dsc.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_dsd.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_arq.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_sbc.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_pkm.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_aas_fbck.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_fpc.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_pmc.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_prc_lt_ctrl.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_aas_beam.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_res_cmd.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_rep.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_clk_cmp.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/msg_dsx_rvd.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_harq_map_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_compact_dlmap_ie_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_compact_ulmap_ie_decoder.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_utils.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/crc.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/crc_data.c.o plugins/epan/wimax/CMakeFiles/wimax.dir/wimax_tlv.c.o -Wl,-rpath,"\$ORIGIN/../../../:" run/libwireshark.so.0.0.0 run/libwsutil.so.0.0.0 /usr/lib64/libglib-2.0.so -Wl,-rpath-link,/var/tmp/portage/net-analyzer/wireshark-9999/work/wireshark-9999_build/run && : /var/tmp/portage/net-analyzer/wireshark-9999/work/wireshark-9999/plugins/epan/wimax/packet-wmx.c:36:14: error: type of ‘include_cor2_changes’ does not match original declaration [-Werror=lto-type-mismatch] 36 | extern bool include_cor2_changes; | ^ /var/tmp/portage/net-analyzer/wireshark-9999/work/wireshark-9999/plugins/epan/wimax/mac_hd_generic_decoder.c:54:10: note: type ‘gboolean’ should match type ‘_Bool’ 54 | gboolean include_cor2_changes; | ^ /var/tmp/portage/net-analyzer/wireshark-9999/work/wireshark-9999/plugins/epan/wimax/mac_hd_generic_decoder.c:54:10: note: ‘include_cor2_changes’ was previously declared here /var/tmp/portage/net-analyzer/wireshark-9999/work/wireshark-9999/plugins/epan/wimax/mac_hd_generic_decoder.c:54:10: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used lto1: some warnings being treated as errors lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-gcc returned 1 exit status compilation terminated. It doesn't build fine either at the moment. :P |