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 USB joystick crashes "testcontroller" app #9021

Closed
mikekov opened this issue Feb 8, 2024 · 5 comments
Closed

Connecting USB joystick crashes "testcontroller" app #9021

mikekov opened this issue Feb 8, 2024 · 5 comments
Assignees
Milestone

Comments

@mikekov
Copy link

mikekov commented Feb 8, 2024

I can cause "testcontroller" app to crash by connecting old USB joystick to my macbook:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1029fd6b56a0)
    frame #0: 0x00000001801378f8 libobjc.A.dylib`objc_retain + 16
libobjc.A.dylib`objc_retain:
->  0x1801378f8 <+16>: ldr    x17, [x17, #0x20]
    0x1801378fc <+20>: tbz    w17, #0x2, 0x1801378b4    ; ___lldb_unnamed_symbol1452
    0x180137900 <+24>: tbz    w16, #0x0, 0x1801378dc    ; ___lldb_unnamed_symbol1452 + 40
    0x180137904 <+28>: lsr    x17, x16, #55
Target 0: (testcontroller) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1029fd6b56a0)
  * frame #0: 0x00000001801378f8 libobjc.A.dylib`objc_retain + 16
    frame #1: 0x0000000100982dc0 libSDL3.1.0.0.dylib`IOS_MFIJoystickUpdate(joystick=0x0000000107f1ca00) at SDL_mfijoystick.m:1159:13
    frame #2: 0x000000010097e9f0 libSDL3.1.0.0.dylib`IOS_JoystickUpdate(joystick=0x0000000107f1ca00) at SDL_mfijoystick.m:1719:9
    frame #3: 0x0000000100830f3c libSDL3.1.0.0.dylib`SDL_OpenJoystick_REAL(instance_id=3) at SDL_joystick.c:1114:5
    frame #4: 0x00000001007eda9c libSDL3.1.0.0.dylib`SDL_OpenJoystick(a=3) at SDL_dynapi_procs.h:527:1
    frame #5: 0x0000000100005078 testcontroller`AddController(id=3, verbose=1) at testcontroller.c:871:32
    frame #6: 0x000000010000369c testcontroller`loop(arg=0x0000000000000000) at testcontroller.c:1513:13
    frame #7: 0x000000010000329c testcontroller`main(argc=1, argv=0x000000016fdff2e8) at testcontroller.c:2108:9
    frame #8: 0x00000001801850e0 dyld`start + 2360

If there's something I can do to help diagnose it further, please let me know.

SDL3 built from master, as of Feb 7, 2024.

@slouken
Copy link
Collaborator

slouken commented Feb 8, 2024

Is controller.physicalInputProfile nil in this case?

@slouken slouken modified the milestones: 2.32.0, 3.2.0 Feb 8, 2024
@slouken slouken self-assigned this Feb 8, 2024
@mikekov
Copy link
Author

mikekov commented Feb 10, 2024

I think controller.physicalInputProfile is not nil: "joy profile: 0x134822df0"

Now I have it crash at this line: for (id key in device->buttons) {.

axis looks valid, but buttons NSArray does not:

image

...but on another attempt it crashes accessing axes:

image

In yet another attempt crash iterating axies, even though array seems to be present:

image

@mikekov
Copy link
Author

mikekov commented Feb 10, 2024

axes is probably collected, as it points to garbage. Removing __unsafe_unretained form its declaration resolves the issue for me, but I don't know why this qualifier was there or how to properly free axes now.

@slouken
Copy link
Collaborator

slouken commented Feb 10, 2024

Good find, thanks! I'll take care of that.

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 is fixed, thanks!

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

2 participants