Skip to content

Controller discovery sometimes hangs for multiple seconds #13236

Closed
@ChillerDragon

Description

@ChillerDragon

I started to notice that in april in the SDL project ddnet (ddnet/ddnet#10034)
It uses SDL2 but I am on archlinux so my system SDL2 is sdl2-compat.

Anyways I can reproduce with the current main branch (d7939ab) and the testcontroller example.

This is the backtrace I get when interrupting with ctrl-c while it hangs

#0  0x00007ffff7aade22 in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff7aa1fda in ?? () from /usr/lib/libc.so.6
#2  0x00007ffff7aa2024 in ?? () from /usr/lib/libc.so.6
#3  0x00007ffff7b1c05e in poll () from /usr/lib/libc.so.6
#4  0x00007ffff75b22b5 in ?? () from /usr/lib/libusb-1.0.so.0
#5  0x00007ffff75b3351 in libusb_handle_events_timeout_completed () from /usr/lib/libusb-1.0.so.0
#6  0x00007ffff75b3402 in libusb_handle_events_completed () from /usr/lib/libusb-1.0.so.0
#7  0x00007ffff75b3462 in ?? () from /usr/lib/libusb-1.0.so.0
#8  0x00007ffff75b4cc8 in libusb_control_transfer () from /usr/lib/libusb-1.0.so.0
#9  0x00007ffff7c898e8 in SDL_libusb_get_string_descriptor (length=0x200, dev=0x55555567fea0, descriptor_index=0x1, lang_id=<optimized out>, 
    data=0x7fffffffc760 "\003") at /home/chiller/Desktop/git/SDL/src/hidapi/SDL_hidapi_libusb.h:92
#10 get_usb_string (dev=dev@entry=0x55555567fea0, idx=0x1) at /home/chiller/Desktop/git/SDL/src/hidapi/libusb/hid.c:381
#11 0x00007ffff7c89c88 in usb_string_cache_find (desc=<optimized out>, handle=<optimized out>)
    at /home/chiller/Desktop/git/SDL/src/hidapi/libusb/hid.c:540
#12 create_device_info_for_device (device=device@entry=0x55555563c240, handle=0x55555567fea0, desc=desc@entry=0x7fffffffcab0, config_number=0x1, 
    interface_num=0x0, interface_class=<optimized out>, interface_subclass=0x1, interface_protocol=0x1)
    at /home/chiller/Desktop/git/SDL/src/hidapi/libusb/hid.c:748
#13 0x00007ffff7c8d9e3 in LIBUSB_hid_enumerate (vendor_id=vendor_id@entry=0x0, product_id=product_id@entry=0x0)
    at /home/chiller/Desktop/git/SDL/src/hidapi/libusb/hid.c:993
#14 0x00007ffff7c8e3c2 in SDL_hid_enumerate_REAL (vendor_id=vendor_id@entry=0x0, product_id=product_id@entry=0x0)
    at /home/chiller/Desktop/git/SDL/src/hidapi/SDL_hidapi.c:1434
#15 0x00007ffff7ded79f in HIDAPI_UpdateDeviceList () at /home/chiller/Desktop/git/SDL/src/joystick/hidapi/SDL_hidapijoystick.c:1115
#16 0x00007ffff7dee073 in HIDAPI_JoystickInit () at /home/chiller/Desktop/git/SDL/src/joystick/hidapi/SDL_hidapijoystick.c:566
#17 0x00007ffff7c9f80d in SDL_InitJoysticks () at /home/chiller/Desktop/git/SDL/src/joystick/SDL_joystick.c:850
#18 0x00007ffff7c4090f in SDL_InitSubSystem_REAL (flags=0x2220) at /home/chiller/Desktop/git/SDL/src/SDL.c:411
#19 0x000055555555e333 in SDL_AppInit (appstate=appstate@entry=0x7ffff7edb040 <SDL_main_appstate>, argc=argc@entry=0x1, 
    argv=argv@entry=0x7fffffffce48) at /home/chiller/Desktop/git/SDL/test/testcontroller.c:2415
#20 0x00007ffff7ca041d in SDL_InitMainCallbacks (argc=0x1, argv=0x7fffffffce48, appinit=0x55555555d9a0 <SDL_AppInit>, appiter=<optimized out>, 
    appevent=<optimized out>, appquit=<optimized out>) at /home/chiller/Desktop/git/SDL/src/main/SDL_main_callbacks.c:104
#21 0x00007ffff7e1c69b in SDL_EnterAppMainCallbacks_REAL (argc=<optimized out>, argv=<optimized out>, appinit=<optimized out>, 
    appiter=<optimized out>, appevent=<optimized out>, appquit=<optimized out>)
    at /home/chiller/Desktop/git/SDL/src/main/generic/SDL_sysmain_callbacks.c:56
#22 0x00007ffff7a376b5 in ?? () from /usr/lib/libc.so.6
#23 0x00007ffff7a37769 in __libc_start_main () from /usr/lib/libc.so.6
#24 0x000055555555b1c5 in _start ()

The issue is tricky to reproduce. I can only reproduce on one specific device. And it also depends if it is in a bad state session or not. Rebooting the pc might fix or reintroduce the issue. Sometimes I do not have it for 10 reboots in a row. But once I have it it does not go away until I reboot again.

I tried downgrading libusb that did not help either.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions