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

Program crashes when controller plugged in #3070

Open
spamzilla opened this issue Nov 17, 2023 · 11 comments
Open

Program crashes when controller plugged in #3070

spamzilla opened this issue Nov 17, 2023 · 11 comments
Labels
blocked:needs info Not enough information to be fully investigated
Milestone

Comments

@spamzilla
Copy link

Just what the title says...

@endrift endrift added the blocked:needs info Not enough information to be fully investigated label Nov 18, 2023
@endrift
Copy link
Member

endrift commented Nov 18, 2023

You're going to need to give me more information. Like, a lot more information. If this happened for everyone with every controller on every OS, you can be sure it'd have been fixed by now.

@Jaizu
Copy link

Jaizu commented Dec 1, 2023

Having the same issue here.
It doesnt crash with my 8 Bit ultimate C controller but it does happen with my official switch pro controller when connected wired.
mGBA Version: 0.10.2
Windows info:
Edition Windows 11 Pro
Version 23H2
Installed on ‎04/‎10/‎2023
OS build 22631.2715
Experience Windows Feature Experience Pack 1000.22677.1000.0
Computer info:
Device name Porygon
Processor AMD Ryzen 5 5600 6-Core Processor 3.50 GHz
Installed RAM 32,0 GB
Device ID B50EF6F1-7BE1-40FB-9BBC-B2EB6AF1EFB6
Product ID 00331-10000-00001-AA584
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display

Edit: I also tested with stuff like Steam not opened to make sure nothing external was messing around with the controllers of my computer, same results. I wanted to test the pro controller wireless but I failed to find my bluetooth dongle lol

@spamzilla
Copy link
Author

Sorry about the vague post. I believe my controller is this one: http://www.pc210.com/products/product_view.aspx?proid=430

@FireSpike0
Copy link

Steps to reproduce:
The bug (or a similar one) also occurs on Linux (NixOS in my case, using the package from Nixpkgs). In my case, it happens in the following situation:

  1. Controller is plugged in, mGBA is started.
  2. A game is started and running (which could be an important part of information).
  3. The controller is disconnected during the game.
  4. The game continues to run.
  5. The controller is reconnected and the player LEDs are blinking.
  6. The game immediately freezes and mGBA becomes unresponsive.
  7. mGBA crashes.

The bug does not immediately appear, but rather requires (when reproducing in a games title screen) a variable amount (un-)plugs of the controller to occur (but sometimes a single (un-)plug is enough).

And before somebody asks: No, I'm disconnecting my controller on purpose during the game, rather my controller is old and has a loose contact which results in short disconnects during the usage.
In one case, it seemed (not entirely sure though) that mGBA crashed instantly after disconnecting the controller.

Additional information:
Before crashing, mGBA is unresponsive for a moment. After about 5 seconds, it crashes without any error message at all and just disappears. Starting it from the commandline and looking at the output after the crash hints, that mGBA has a segfault in this case:

QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined
QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined
QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined
[1]    19405 segmentation fault (core dumped)  mgba-qt

Information about my setup / system:
mGBA version: 0.10.2
OS: NixOS Unstable, 64 Bit AMD64 / x86_64
CPU: Intel(R) Core(TM) i3 CPU M370, 4 cores with 2.40GHz each

If this seems to be another issue, I'll create a new issue. But at the moment it looks like it could probably be the same issue.

@endrift endrift added pending This issue needs more investigation by a maintainer to triage appropriately and removed blocked:needs info Not enough information to be fully investigated labels Dec 12, 2023
@endrift endrift added this to the mGBA 0.10.4 milestone Dec 12, 2023
@FireSpike0
Copy link

@spamzilla @Jaizu Was a game already running when mGBA crashed? If yes, it could probably prove my theory...

I just took another look into it and threw gdb on it; I guess (in my case) the problem occurs through the invalidated reference when disconnecting the controller / the incompletely initialized reference when newly connecting a controller while the inputs are polled. At least thats's what I think could be the problem:

#0  0x0000000000000000 in ?? ()
#1  0x00000000005428e5 in QGBA::InputController::pollEvents (this=0xa288a8)
    at /home/user/Repositories/mgba/src/platform/qt/InputController.cpp:350
#2  0x00000000004f1503 in QGBA::CoreController::updateKeys (this=this@entry=0xbe2ea0)
    at /home/user/Repositories/mgba/src/platform/qt/CoreController.cpp:1207
#3  0x00000000004f48b5 in QGBA::CoreController::finishFrame (this=0xbe2ea0)
    at /home/user/Repositories/mgba/src/platform/qt/CoreController.cpp:1254
#4  0x00007ffff79072ac in GBAFrameEnded (gba=0x7fffbc002000)
    at /home/user/Repositories/mgba/src/gba/gba.c:974
#5  0x00007ffff792ac8f in _startHdraw (timing=<optimized out>, context=0x7fffbc002c90, 
    cyclesLate=0) at /home/user/Repositories/mgba/src/gba/video.c:181
#6  0x00007ffff78a02e2 in mTimingTick (timing=timing@entry=0x7fffbc003960, 
    cycles=cycles@entry=215) at /home/user/Repositories/mgba/src/core/timing.c:106
#7  0x00007ffff7905a7a in GBAProcessEvents (cpu=0x7fffbc69d000)
    at /home/user/Repositories/mgba/src/gba/gba.c:316
#8  0x00007ffff789f179 in _mCoreThreadRun (context=0xbe2eb0)
    at /home/user/Repositories/mgba/src/core/thread.c:339
#9  0x00007ffff3ca3084 in start_thread ()
   from /nix/store/9y8pmvk8gdwwznmkzxa6pwyah52xy3nk-glibc-2.38-27/lib/libc.so.6
#10 0x00007ffff3d2560c in clone3 ()
   from /nix/store/9y8pmvk8gdwwznmkzxa6pwyah52xy3nk-glibc-2.38-27/lib/libc.so.6

And even if my guess is incorrect, there's probably additional useful information about the bug.

@endrift endrift modified the milestones: mGBA 0.10.4, mGBA 0.10.3 Dec 21, 2023
@endrift
Copy link
Member

endrift commented Dec 21, 2023

Pulling this into 0.10.3 since it seems more widespread than I'd originally expected.

@endrift
Copy link
Member

endrift commented Dec 21, 2023

I am unable to reproduce a crash on 0.10.2, at least on Linux. I can, however, reproduce a crash on disconnect on master that I'm looking into now.

@endrift
Copy link
Member

endrift commented Dec 21, 2023

I have fixed the crash on master. I'll look at 0.10.2 on Windows soon.

@endrift
Copy link
Member

endrift commented Dec 25, 2023

Try as I might, I can't reproduce this on Windows 10 with 0.10.2. Can I get precise reproduction steps?

@endrift endrift added blocked:needs info Not enough information to be fully investigated and removed pending This issue needs more investigation by a maintainer to triage appropriately labels Dec 25, 2023
@endrift endrift modified the milestones: mGBA 0.10.3, mGBA 0.10.4 Dec 25, 2023
@FireSpike0
Copy link

FireSpike0 commented Feb 23, 2024

Is the fix for the crash incorporated in the current 0.10.3 release? If yes, the bug is not fixed on version 0.10.3 on NixOS. If not, I would compile the master branch on my machine and test it.
In any case: Thanks for looking into it so far :)

@endrift
Copy link
Member

endrift commented Feb 23, 2024

If it were, this bug would have been closed. I don't have a repro case for the 0.10.2 crash. The fix on master is for a different crash that only existed on master. That said, the backtrace you posted doesn't seem to be for 0.10.2--that line isn't in that function on that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked:needs info Not enough information to be fully investigated
Projects
None yet
Development

No branches or pull requests

4 participants