Skip to content
New issue

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

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

Already on GitHub? # to your account

internal/gamepad: crash when connecting an XInput device and then connecting a DInput device #3047

Closed
1 of 11 tasks
hajimehoshi opened this issue Jul 20, 2024 · 3 comments
Closed
1 of 11 tasks

Comments

@hajimehoshi
Copy link
Owner

Ebitengine Version

687e505

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

go version go1.22.0 windows/arm64

What steps will reproduce the problem?

Run examples/gamepad and try connecting and disconnecting two PS4 gamepads

What is the expected result?

No crash

What happens instead?

Crash

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7ff6c9dd9b60]

goroutine 1 [running, locked to thread]:
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*_IDirectInputDevice8W).GetProperty(0x4000822ca0?, 0x40001242a0?, 0x104?)
        Z:/ebiten/internal/gamepad/api_desktop_windows.go:420 +0x20
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*nativeGamepadsDesktop).dinput8EnumDevicesCallback.func1(0x0?)
        Z:/ebiten/internal/gamepad/gamepad_desktop_windows.go:319 +0x58
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*nativeGamepadsDesktop).dinput8EnumDevicesCallback.func2(0x5c4054c?)
        Z:/ebiten/internal/gamepad/gamepad_desktop_windows.go:333 +0x58
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*gamepads).find(...)
        Z:/ebiten/internal/gamepad/gamepad.go:134
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*nativeGamepadsDesktop).dinput8EnumDevicesCallback(0x4000448bd0, 0x6cecbff598, 0x7ff6ca2254a0)
        Z:/ebiten/internal/gamepad/gamepad_desktop_windows.go:332 +0x210
syscall.SyscallN(0x0?, {0x40008239a8?, 0x1?, 0x0?})
        C:/Program Files/Go/src/runtime/syscall_windows.go:544 +0xe8
syscall.Syscall6(0x0?, 0x41059a?, 0x40005391f8?, 0x0?, 0x4000823ab8?, 0x7ff6c9d942ac?, 0x4000823aa8?, 0x7ff6c9bc057c?)
        C:/Program Files/Go/src/runtime/syscall_windows.go:488 +0x40
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*_IDirectInput8W).EnumDevices(0x4001003a88?, 0xfb0d0be8?, 0x1000110?, 0x186fb0d0be8?, 0x10?)
        Z:/ebiten/internal/gamepad/api_desktop_windows.go:334 +0x50
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*nativeGamepadsDesktop).detectConnection(0x4000448bd0, 0x7ff6ca2254a0)
        Z:/ebiten/internal/gamepad/gamepad_desktop_windows.go:232 +0xb4
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*nativeGamepadsDesktop).update(0x4000448bd0, 0x7ff6c9e4201c?)
        Z:/ebiten/internal/gamepad/gamepad_desktop_windows.go:573 +0xec
github.com/hajimehoshi/ebiten/v2/internal/gamepad.(*gamepads).update(0x7ff6ca2254a0)
        Z:/ebiten/internal/gamepad/gamepad.go:97 +0x104
github.com/hajimehoshi/ebiten/v2/internal/gamepad.Update(...)
        Z:/ebiten/internal/gamepad/gamepad.go:62
github.com/hajimehoshi/ebiten/v2/internal/ui.(*UserInterface).updateInputStateImpl(0x40002cedc8)
        Z:/ebiten/internal/ui/input_glfw.go:119 +0x308
github.com/hajimehoshi/ebiten/v2/internal/ui.(*UserInterface).updateInputState.func1()
        Z:/ebiten/internal/ui/input_glfw.go:60 +0x28
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop.func1({0x4000005470?, 0x60?}, 0x40002274f0?)
        Z:/ebiten/internal/thread/thread.go:67 +0x5c
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop(0x40002274f0, {0x7ff6c9fb5d78, 0x40005e5d10})
        Z:/ebiten/internal/thread/thread.go:68 +0x60
github.com/hajimehoshi/ebiten/v2/internal/ui.(*UserInterface).runMultiThread(0x40002cedc8, {0x7ff6c9fb7c48, 0x4000243650}, 0x4000450810)
        Z:/ebiten/internal/ui/run.go:75 +0x2fc
github.com/hajimehoshi/ebiten/v2/internal/ui.(*UserInterface).Run(0x7ff6c9fb49b8?, {0x7ff6c9fb7c48?, 0x4000243650?}, 0x7ff6ca2262c0?)
        Z:/ebiten/internal/ui/run.go:33 +0x3c
github.com/hajimehoshi/ebiten/v2.RunGameWithOptions({0x7ff6c9fb49b8, 0x40004507e0}, 0x0)
        Z:/ebiten/run.go:327 +0x210
github.com/hajimehoshi/ebiten/v2.RunGame(...)
        Z:/ebiten/run.go:235
main.main()
        Z:/ebiten/examples/gamepad/main.go:212 +0x54
exit status 2

Anything else you feel useful to add?

Unfortunately it is hard to reproduce this in a stable way.

@hajimehoshi
Copy link
Owner Author

Now I cannot reproduce the issue... 😢

@hajimehoshi
Copy link
Owner Author

hajimehoshi commented Jul 20, 2024

From the log, it seems device was nil. So probably didn't CreateDevice set a new device but didn't return an error?

@hajimehoshi
Copy link
Owner Author

OK this was easily reproduced by

  1. Connect an XInput device
  2. Connect a DInput device like a PS4 controller

Apparently, Parallels somtimes tries to connect a pseudo XInput device, which happened before.

@hajimehoshi hajimehoshi modified the milestones: v2.8.0, v2.7.8 Jul 20, 2024
@hajimehoshi hajimehoshi changed the title internal/gamepad: crash when connecting and disconnecting two PS4 gamepads internal/gamepad: crash when connecting an XInput device and then connecting a DInput device Jul 20, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant