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

SIGSEV @ SDL_joystick.c:2446 #11904

Open
isXander opened this issue Jan 9, 2025 · 8 comments
Open

SIGSEV @ SDL_joystick.c:2446 #11904

isXander opened this issue Jan 9, 2025 · 8 comments
Assignees
Labels
waiting Waiting on user response
Milestone

Comments

@isXander
Copy link
Contributor

isXander commented Jan 9, 2025

Android build of SDL3 causes a SIGSEV when disconnecting a controller.

void SDL_UpdateJoysticks(void)
{
    /* this needs to happen AFTER walking the joystick list above, so that any
       dangling hardware data from removed devices can be free'd
     */
    for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
        SDL_joystick_drivers[i]->Detect(); // THIS LINE
    }
}

Attached is the log file generated by the JVM with info that may help.
hs_err_pid12511.log

I wouldn't know how to debug this, so please let me know what more info you need.

@icculus icculus added this to the 3.2.0 milestone Jan 10, 2025
@slouken
Copy link
Collaborator

slouken commented Jan 11, 2025

Are you able to reproduce this with testcontroller? I can create an apk of that if that's helpful.

@isXander
Copy link
Contributor Author

That would be quite helpful. (aarch64)

@slouken
Copy link
Collaborator

slouken commented Jan 12, 2025

@AntTheAlchemist
Copy link
Contributor

@isXander I'm not able to reproduce this at all. Which gamepad caused this? Was it USB or Bluetooth? Which Android device? Are you able to reproduce it with a minimal test?

@isXander
Copy link
Contributor Author

This happened on my PR branch. Maybe it could have possibly introduced a regression?

I was not able to reproduce on testcontroller. I think I may know why:

If you notice, when disconnecting a controller on Android, it takes up to 3 seconds for testcontroller to notice this and remove it. android/SDL_sysjoystick.c#ANDROID_JoystickDetect is the code responsible for this delay. It polls every 3 seconds.
Side note: the comment within this method says you have to do it this way because the API to hook correctly is >=16, but the android-project has a minimum API of 21?

My game polls events at 20 ticks per second, calling SDL_PumpEvents() as a result. My theory is that as a result, SDL tries to interact with the controller after Android no longer provides it via SDL_UpdateJoysticks. Taken from the JVM crash log I sent in the original issue post, here is the stack:

Native frames: (J/j=Java code, C=native code)
C  [libSDL3.so+0xcaee8]  SDL_UpdateJoysticks+0x22c (SDL_joystick.c:L2446)
C  [libSDL3.so+0xa8210] (SDL_events.c:L1402)
C  [libjnidispatch.so+0x14050]
C  [libjnidispatch.so+0x10a0c]
C  [libjnidispatch.so+0x7560]
C  [libjnidispatch.so+0x11024]
C  [libjnidispatch.so+0x141e4]
J 26320  dev.isxander.sdl3java.api.events.SdlEvents.SDL_PumpEvents()V (0 bytes) @ 0x0000006ff9f635e0 [0x0000006ff9f63540+0x00000000000000a0]
C  0x00000070938f9490

@isXander I'm not able to reproduce this at all. Which gamepad caused this? Was it USB or Bluetooth? Which Android device? Are you able to reproduce it with a minimal test?

This was on Android 15 (Pixel 9 Pro XL), with a Bluetooth-connected DualSense controller.

@slouken
Copy link
Collaborator

slouken commented Jan 12, 2025

testcontroller polls every frame, probably around 60 FPS on that device. Are you thinking the lower rate is causing the issue?

@isXander
Copy link
Contributor Author

I'm really not sure, could you provide the commands needed to build that testcontroller apk so I can have a mess around and see if I can repeat it? Any OS, whatever's easiest, I have access to them all.

@slouken
Copy link
Collaborator

slouken commented Jan 12, 2025

Sure, I did something like this:

mkdir build
cd build
../build-scripts/create-android-project.py --variant symlink org.libsdl.testcontroller ../test/testcontroller.c ../test/gamepad* ../test/testutils* ../src/test/*

and then executed the gradle command that was spit out.

@slouken slouken added the waiting Waiting on user response label Jan 15, 2025
@slouken slouken modified the milestones: 3.2.0, 3.x Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting on user response
Projects
None yet
Development

No branches or pull requests

4 participants