Bug 513074

Summary: Crashes in in SDL_wcslen_REAL every time you click on System Settings -> Game Controller
Product: [Applications] systemsettings Reporter: Giuseppe Della Bianca <giusdbg>
Component: kcm_joystickAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: crash CC: duha.bugs, josh, jpwhiting, kdedev, pallaswept
Priority: NOR    
Version First Reported In: 6.5.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: To resolve the crashes
To read the manufacturer (if it isn't retrieved from the device by udev) from the udev database

Description Giuseppe Della Bianca 2025-12-08 10:10:42 UTC
Crashes every time you click on System Settings -> Game Controller

This bug has a precise explanation and an easy fix.

Bug 511859

Application: systemsettings (6.5.3)

ApplicationNotResponding [ANR]: false
Qt Version: 6.10.1
Frameworks Version: 6.20.0
Operating System: Linux 6.17.9-300.fc43.x86_64 x86_64
Windowing System: Wayland
Distribution: "Fedora Linux 43 (Workstation Edition)"
DrKonqi: 6.5.3 [CoredumpBackend]

-- Information about the crash:
(gdb) bt
#0  0x00007ffff4559ddd in __wcslen_avx2 () from /lib64/libc.so.6
>>>> #1  0x00007fff8f4bcfe9 in SDL_wcslen_REAL (string=0x0) at /usr/src/debug/SDL3-3.2.24-1.fc43.x86_64/src/stdlib/SDL_string.c:751 <<<<
#2  SDL_wcsdup_REAL (string=0x0) at /usr/src/debug/SDL3-3.2.24-1.fc43.x86_64/src/stdlib/SDL_string.c:805
#3  0x00007fffb00834cb in SDL_hid_enumerate_REAL (vendor_id=<optimized out>, product_id=<optimized out>)
    at /usr/src/debug/sdl2-compat-2.32.56-2.fc43.x86_64/src/sdl2_compat.c:11742
#4  0x00007fffb00d1f5f in getJoystickHidInfo (vendor=1133, product=-15718, path="/dev/input/event8")
    at /usr/src/debug/plasma-desktop-6.5.2-1.fc43.x86_64/kcms/gamecontroller/device.cpp:90
#5  Device::open (this=0x555556d9e2e0) at /usr/src/debug/plasma-desktop-6.5.2-1.fc43.x86_64/kcms/gamecontroller/device.cpp:160
#6  Device::open (this=0x555556d9e2e0) at /usr/src/debug/plasma-desktop-6.5.2-1.fc43.x86_64/kcms/gamecontroller/device.cpp:148
#7  DeviceModel::addDevice (this=this@entry=0x5555561fa590, deviceIndex=0)
    at /usr/src/debug/plasma-desktop-6.5.2-1.fc43.x86_64/kcms/gamecontroller/devicemodel.cpp:132
#8  0x00007fffb00d3edb in DeviceModel::poll (this=<optimized out>)
    at /usr/src/debug/plasma-desktop-6.5.2-1.fc43.x86_64/kcms/gamecontroller/devicemodel.cpp:93
#9  0x00007ffff4b6855a in void doActivate<false>(QObject*, int, void**) () from /lib64/libQt6Core.so.6
#10 0x00007ffff4b76fd4 in QSingleShotTimer::timerEvent(QTimerEvent*) () from /lib64/libQt6Core.so.6
#11 0x00007ffff4b599d5 in QObject::event(QEvent*) () from /lib64/libQt6Core.so.6
#12 0x00007ffff5e3db1f in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib64/libQt6Widgets.so.6
#13 0x00007ffff4afcaa8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib64/libQt6Core.so.6
#14 0x00007ffff4cd1eb8 in QTimerInfoList::activateTimers() () from /lib64/libQt6Core.so.6
#15 0x00007ffff4e20db9 in timerSourceDispatch(_GSource*, int (*)(void*), void*) () from /lib64/libQt6Core.so.6
#16 0x00007ffff3c742a3 in g_main_context_dispatch_unlocked.lto_priv () from /lib64/libglib-2.0.so.0
#17 0x00007ffff3c7d1f8 in g_main_context_iterate_unlocked.isra () from /lib64/libglib-2.0.so.0
#18 0x00007ffff3c7d3a3 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#19 0x00007ffff4e210ad in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt6Core.so.6
#20 0x00007ffff4b09603 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt6Core.so.6
#21 0x00007ffff4b04df9 in QCoreApplication::exec() () from /lib64/libQt6Core.so.6
#22 0x0000555555559735 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/plasma-systemsettings-6.5.2-1.fc43.x86_64/app/main.cpp:175

(gdb) frame 3
#3  0x00007fffabfbb4cb in SDL_hid_enumerate_REAL (vendor_id=<optimized out>, product_id=<optimized out>)
    at /usr/src/debug/sdl2-compat-2.32.56-2.fc43.x86_64/src/sdl2_compat.c:11742
11742               wchar_t *manufacturer_string = SDL3_wcsdup(i->manufacturer_string);

(gdb) list
11737           SDL_hid_device_info *i;
11738           for (i = list3; i != NULL; i = i->next) {
11739               SDL2_hid_device_info *info = (SDL2_hid_device_info *) SDL3_calloc(1, sizeof (SDL2_hid_device_info));
11740               char *path = SDL3_strdup(i->path);
11741               wchar_t *serial_number = SDL3_wcsdup(i->serial_number);
11742               wchar_t *manufacturer_string = SDL3_wcsdup(i->manufacturer_string);
11743               wchar_t *product_string = SDL3_wcsdup(i->product_string);
11744               if (!info || !path || !serial_number || !manufacturer_string || !product_string) {
11745                   SDL_hid_free_enumeration(retval);
11746                   SDL3_free(info);

(gdb) p i
$1 = (SDL_hid_device_info *) 0x555556871700

(gdb) p *i
$2 = {path = 0x555556301a00 "/dev/hidraw6", vendor_id = 1133, product_id = 49818, serial_number = 0x5555563019e0 L"", release_number = 4903, 
  manufacturer_string = 0x0, product_string = 0x555556c0e8e0 L"Driving Force GT", usage_page = 1, usage = 4, interface_number = 0, interface_class = 0, 
  interface_subclass = 0, interface_protocol = 0, bus_type = SDL_HID_API_BUS_USB, next = 0x0}

(gdb) p i->manufacturer_string 
$4 = 0x0


Under the same conditions, jstest-gtk works fine.


Bus 001 Device 002: ID 046d:c29a Logitech, Inc. Driving Force GT

Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 [unknown]
  bDeviceSubClass         0 [unknown]
  bDeviceProtocol         0 
  bMaxPacketSize0        16
  idVendor           0x046d Logitech, Inc.
  idProduct          0xc29a Driving Force GT
  bcdDevice           13.27
  iManufacturer           0 
  iProduct                2 Driving Force GT
  iSerial                 0 
  bNumConfigurations      1

The crash can be reproduced every time.
Comment 1 TraceyC 2025-12-08 17:55:03 UTC
*** Bug 511624 has been marked as a duplicate of this bug. ***
Comment 2 TraceyC 2025-12-08 17:56:21 UTC
Thanks for the crash report. This was already confirmed, so marking this report as confirmed.
Comment 3 Giuseppe Della Bianca 2025-12-20 23:10:21 UTC
Created attachment 187827 [details]
To resolve the crashes

To resolve the crashes

sdl2-compat-release-2.32.56.patch
Comment 4 Giuseppe Della Bianca 2025-12-20 23:11:21 UTC
Created attachment 187828 [details]
To read the manufacturer (if it isn't retrieved from the device by udev) from the udev database

To read the manufacturer (if it isn't retrieved from the device by udev) from the udev database
Comment 5 TraceyC 2025-12-23 00:23:39 UTC
(In reply to Giuseppe Della Bianca from comment #3)
> Created attachment 187827 [details]
> To resolve the crashes
> 
> To resolve the crashes
> 
> sdl2-compat-release-2.32.56.patch

Thanks for the patch! The KDE bug tracker is for bugs rather than development work, however.

The next step is to create a merge request. In the MR, please add "Fixes: Bug xxx" so it gets linked to this report.
https://community.kde.org/Infrastructure/GitLab#Submitting_a_merge_request

If you want to discuss the development work, please reach out in our Matrix channel for new contributors
https://community.kde.org/Get_Involved#New_Contributor?_Say_Hello_In_Matrix

If you need information on getting started with KDE development, please see
[https://community.kde.org/Get_Involved/development](https://community.kde.org/Get_Involved/development)

Thanks again.
Comment 6 Giuseppe Della Bianca 2025-12-24 09:11:21 UTC
(In reply to TraceyC from comment #5)
> (In reply to Giuseppe Della Bianca from comment #3)
> > Created attachment 187827 [details]
> > To resolve the crashes
...
> Thanks for the patch! The KDE bug tracker is for bugs rather than
> development work, however.
..... 
> Thanks again.

I also sent the patches to whoever manages sdl2-compat and SDL3.

https://github.com/libsdl-org/sdl2-compat/commit/8b85f95bbcc3411c78c1f2cbd62b23b7f96093c2

https://github.com/libsdl-org/SDL/pull/14688