Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting generic USB joystick crashes SDL2 apps #9042

Closed
mikekov opened this issue Feb 10, 2024 · 6 comments
Closed

Connecting generic USB joystick crashes SDL2 apps #9042

mikekov opened this issue Feb 10, 2024 · 6 comments

Comments

@mikekov
Copy link

mikekov commented Feb 10, 2024

"testjoystick" can be used to test joystick crash on macOS with latest build of SDL2. All it takes is connecting the generic USB joystick:

image

hid_enumerate from "mac" folder has a chance to execute once after joystick is connected. Then, on a second run, macOS encounters this problem.

If there's something to work around this bug, I can try it...

@slouken
Copy link
Collaborator

slouken commented Feb 11, 2024

I'm pretty sure this is a duplicate of #9021. I plan on looking at that next week.

@mikekov
Copy link
Author

mikekov commented Feb 11, 2024

This is an SDL2 branch, so SDL_mfijoystick.m is nowhere to be seen here? I thought it was actually macOS bug, but reported it anyway.

slouken added a commit that referenced this issue Feb 12, 2024
slouken added a commit that referenced this issue Feb 12, 2024
Fixes #9021
Fixes #9042

(cherry picked from commit 42cdbf6)
(cherry picked from commit 971c5c2)
@slouken
Copy link
Collaborator

slouken commented Feb 12, 2024

This should be fixed in the latest main and SDL2 code. Please let me know if you're still having issues?

@mikekov
Copy link
Author

mikekov commented Feb 12, 2024

Thank you, generic joystick now works as expected (tested in SDL2 branch).

However, I ran into another issue with an old USB gamepad (Chinese InNext SNES controller). Connecting it while "testjoystick" is running leads to a crash here:

* thread #1, queue = 'GCDevicePhysicalInput', stop reason = EXC_BAD_ACCESS (code=1, address=0xf7f7f7f7f20)
    frame #0: 0x00000001883f78f8 libobjc.A.dylib`objc_retain + 16
libobjc.A.dylib`objc_retain:
->  0x1883f78f8 <+16>: ldr    x17, [x17, #0x20]
    0x1883f78fc <+20>: tbz    w17, #0x2, 0x1883f78b4    ; ___lldb_unnamed_symbol1452
    0x1883f7900 <+24>: tbz    w16, #0x0, 0x1883f78dc    ; ___lldb_unnamed_symbol1452 + 40
    0x1883f7904 <+28>: lsr    x17, x16, #55
Target 0: (testjoystick) stopped.
(lldb) bt
* thread #1, queue = 'GCDevicePhysicalInput', stop reason = EXC_BAD_ACCESS (code=1, address=0xf7f7f7f7f20)
  * frame #0: 0x00000001883f78f8 libobjc.A.dylib`objc_retain + 16
    frame #1: 0x00000001883fdaf8 libobjc.A.dylib`objc_storeStrong + 48
    frame #2: 0x000000019ffbfd60 GameController`-[_GCDevicePhysicalInputElementParameters copyWithZone:] + 96
    frame #3: 0x000000019ffca1dc GameController`-[_GCDevicePhysicalInputButtonElementParameters copyWithZone:] + 52
    frame #4: 0x000000019ffd9dc4 GameController`__50-[_GCControllerInputComponent setSettingsProfile:]_block_invoke + 896
    frame #5: 0x0000000188612cb8 libdispatch.dylib`_dispatch_call_block_and_release + 32
    frame #6: 0x0000000188614910 libdispatch.dylib`_dispatch_client_callout + 20
    frame #7: 0x000000018861bea4 libdispatch.dylib`_dispatch_lane_serial_drain + 748
    frame #8: 0x000000018861ca08 libdispatch.dylib`_dispatch_lane_invoke + 432
    frame #9: 0x0000000188622eb8 libdispatch.dylib`_dispatch_main_queue_drain + 744
    frame #10: 0x0000000188622bc0 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 44
    frame #11: 0x00000001888e4ea4 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
    frame #12: 0x00000001888a2760 CoreFoundation`__CFRunLoopRun + 1996
    frame #13: 0x00000001888a193c CoreFoundation`CFRunLoopRunSpecific + 608
    frame #14: 0x000000010077ddd8 libSDL2-2.0.0.dylib`process_pending_events at hid.c:510:9
    frame #15: 0x000000010077a9d4 libSDL2-2.0.0.dylib`PLATFORM_hid_enumerate(vendor_id=0, product_id=0) at hid.c:529:2
    frame #16: 0x000000010077cbd8 libSDL2-2.0.0.dylib`SDL_hid_enumerate_REAL(vendor_id=0, product_id=0) at SDL_hidapi.c:1282:20
    frame #17: 0x00000001008e33ac libSDL2-2.0.0.dylib`HIDAPI_UpdateDeviceList at SDL_hidapijoystick.c:1104:16
    frame #18: 0x00000001008e3d90 libSDL2-2.0.0.dylib`HIDAPI_JoystickDetect at SDL_hidapijoystick.c:1319:13
    frame #19: 0x000000010078afa8 libSDL2-2.0.0.dylib`SDL_JoystickUpdate_REAL at SDL_joystick.c:2198:9
    frame #20: 0x0000000100769ea8 libSDL2-2.0.0.dylib`SDL_PumpEventsInternal(push_sentinel=SDL_TRUE) at SDL_events.c:931:9
    frame #21: 0x000000010076a030 libSDL2-2.0.0.dylib`SDL_WaitEventTimeout_REAL(event=0x000000016fdfef68, timeout=0) at SDL_events.c:1100:9
    frame #22: 0x0000000100769fb4 libSDL2-2.0.0.dylib`SDL_PollEvent_REAL(event=0x000000016fdfef68) at SDL_events.c:967:12
    frame #23: 0x000000010074d834 libSDL2-2.0.0.dylib`SDL_PollEvent(a=0x000000016fdfef68) at SDL_dynapi_procs.h:156:1
    frame #24: 0x0000000100003248 testjoystick`loop(arg=<unavailable>) at testjoystick.c:115:12 [opt]
    frame #25: 0x00000001000039e8 testjoystick`main(argc=<unavailable>, argv=<unavailable>) at testjoystick.c:320:9 [opt]
    frame #26: 0x00000001884450e0 dyld`start + 2360

I can report separate issue, if this is unrelated...

@natbro
Copy link

natbro commented Feb 12, 2024

he @mikekov - this looks like it's in the GameController framework - would you mind either filing a feedback with a sysdiagnose at https://feedbackassistant.apple.com and letting me know the number, or capturing a sysdiagnose and sending it to me at natbro@apple.com? haven't seen this one.

@mikekov
Copy link
Author

mikekov commented Feb 13, 2024

I tried, feedbackassistant is not working (blank page) and sysdiagnose dump is too big for sending by e-mail.


Update: sent diagnostics to natbro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants