Udisks2 Segfaults when Turning Off Devices
Command segfaults:
$ udisksctl power-off -b /dev/sdb
(udisksctl power-off:19392): GLib-GIO-CRITICAL **: 15:05:24.205: g_dbus_interface_dup_object: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Segmentation fault
[22835.388282] udisksctl[20742]: segfault at 0 ip 00007fe7c110ee6f sp 00007ffc2282c540 error 4 in libgio-2.0.so.0.7000.2[7fe7c101e000+113000]
[22835.388460] Code: 27 ff ff ff 48 8b 7d 00 48 89 c6 e8 9b 12 f1 ff 48 89 ef 5d 48 8b 40 18 ff e0 90 41 54 49 89 f4 55 48 89 fd 53 e8 01 ff ff ff <48> 8b 7d 00 48 89 c6 e8 75 12 f1 ff 4c 89 e7 48 89 c3 e8 5a 4a fd
System has polkit installed, but not running. Same issue even if polktd is running.
System uses seatd instead of elogind.
Checked an older MLFS build.... udisksctl did not segfaut. old MLFS build had udisks-2.9.1, elogind, and glib-2.66.4. Build was running on a 32-bit x86 laptop.
Downgraded udisks2 from 2.9.4 to 2.9.1 .... still segfaults Installed elogind .... still segfaults.
Issue with newer glib? ~~or does polkitd need to be running?~~ Tested polkit working, but udisksctl still segfaults
Preloading udisksctl with glib-2.66.4's libgio did not work: still segfaults.
Rebuilt udisk2 without stripping the debug symbols. Installed the GNU debugger (gdb) to interpret core dumps.
Inserted a USB flash drive into machine.
Enable core dumps: $ ulimit -c unlimited
Then executed: udisksctl power-off -b /dev/sda
Same issue: udiskctl segfaults.
Used gdb to inspect core dump: $ gdb udisksctl core
Output:
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from udisksctl...
[New LWP 619]
[New LWP 620]
[New LWP 621]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `udisksctl power-off -b /dev/sda'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f5128b85b8f in g_dbus_object_get_interface () from /usr/lib/libgio-2.0.so.0
[Current thread is 1 (Thread 0x7f51286f4ec0 (LWP 619))]
(gdb) bt
#0 0x00007f5128b85b8f in g_dbus_object_get_interface () at /usr/lib/libgio-2.0.so.0
#1 0x00007f5128e70b72 in udisks_object_peek_drive () at /usr/lib/libudisks2.so.0
#2 0x000055803c0ba309 in handle_command_power_off ()
#3 0x000055803c0bcb23 in main ()
~~When comparing udisksctl and libgio on two different systems (one system has a non-seg-faulting udisks) the system with out udisks segfaults did not have udisksctl and libgio linked to /usr/lib/libterminfo.so or any curses library.~~
When using readelf -d on both built libgio libraries, both are linked to the same libraries, no libterminfo linked.
If i check what libraries are linked for a segfaulting udisksctl:
$ readelf -d /usr/bin/udisksctl
Dynamic section at offset 0xed68 contains 33 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libpolkit-agent-1.so.0]
0x0000000000000001 (NEEDED) Shared library: [libpolkit-gobject-1.so.0]
0x0000000000000001 (NEEDED) Shared library: [libudisks2.so.0]
0x0000000000000001 (NEEDED) Shared library: [libgobject-2.0.so.0]
0x0000000000000001 (NEEDED) Shared library: [libglib-2.0.so.0]
0x0000000000000001 (NEEDED) Shared library: [libgio-2.0.so.0]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x4000
0x000000000000000d (FINI) 0xbf04
It lacks a library, compared to a udisksctl that does not segfault:
$ readelf -d /usr/bin/udisksctl
Dynamic section at offset 0xed68 contains 31 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libpolkit-agent-1.so.0]
0x0000000000000001 (NEEDED) Shared library: [libexpat.so.1]
0x0000000000000001 (NEEDED) Shared library: [libpolkit-gobject-1.so.0]
0x0000000000000001 (NEEDED) Shared library: [libudisks2.so.0]
0x0000000000000001 (NEEDED) Shared library: [libgobject-2.0.so.0]
0x0000000000000001 (NEEDED) Shared library: [libglib-2.0.so.0]
0x0000000000000001 (NEEDED) Shared library: [libgio-2.0.so.0]
0x0000000000000001 (NEEDED) Shared library: [libc.musl-x86_64.so.1]
0x000000000000000c (INIT) 0x4000
0x000000000000000d (FINI) 0xc771
The non-segfaulting binary has libexpat linked.
Looks like building LVM2 without symvers fixes issue ... per commit 3682c6062a84834edd5e264a787ecd4ad70e4aae