Wireshark crashes on exit when using `wmem_register_callback` in a plugin
Summary
When registering any callback using wmem_register_callback
inside an external C plugin, the application crashes on exit instead of exiting cleanly.
Steps to reproduce
Write an external epan plugin, register any callback using wmem_register_callback
, compile and run from the command line, exit from the GUI normally.
What is the current bug behavior?
When running from the command line, after trying to exit from the GUI, a Segmentation fault is thrown (on Linux).
The issue is that the callback is called on exit only after the shared library of the plugin has been unloaded, resulting in a segfault.
What is the expected correct behavior?
The application should exit cleanly.
Sample capture file
(If possible attach a sample capture file showing this issue)
Relevant logs and/or screenshots
Truncated strace output together with print added inside wmem_call_callbacks
:
openat(AT_FDCWD, "/path/to/plugin.so", O_RDONLY|O_CLOEXEC) = 16
mmap(NULL, 40264, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 16, 0) = 0x7f911623c000
munmap(0x7f911623c000, 40264) = 0
write(2, "calling callback at 0x7f911623f8"..., 34calling callback at 0x7f911623f880) = 34
write(2, "\n", 1
) = 1
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x7f911623f880} ---
+++ killed by SIGSEGV (core dumped) +++
Build information
Version 4.3.0 (v4.3.0rc0-1157-gb8e7db6600a8).
Compiled (64-bit) using GCC 11.4.0, with GLib 2.72.4, with Qt 6.2.4, with
libpcap, without POSIX capabilities, without libnl, with zlib 1.2.11, with
PCRE2, without Lua, without GnuTLS, with Gcrypt 1.9.4, without Kerberos, without
MaxMind, without nghttp2, without nghttp3, without brotli, without LZ4, without
Zstandard, without Snappy, without libxml2, without libsmi, with QtMultimedia,
without automatic updates, without Minizip, with binary plugins.
Running on Linux 5.15.133.1-microsoft-standard-WSL2, with 11th Gen Intel(R)
Core(TM) i7-1165G7 @ 2.80GHz (with SSE4.2), with 7807 MB of physical memory,
with GLib 2.72.4, with Qt 6.2.4, with libpcap 1.10.1 (with TPACKET_V3), with
zlib 1.2.11, with PCRE2 10.39 2021-10-29, with c-ares 1.18.1, with Gcrypt 1.9.4,
with light display mode, without HiDPI, with QPA plugin "xcb", with
LC_TYPE=C.UTF-8, binary plugins supported.