Skip to content

Using input method causes game to crash #257

Closed
@LordCocoNut

Description

@LordCocoNut

I'm using an input method of the godot-api for a custom Npc class like so:

#[godot_api]
impl CharacterBody3DVirtual for Npc {
   ...
    fn input(&mut self, event: Gd<InputEvent>) {
   }
}

When i have gamepad connected to the pc (probably cause of joypad continuous input) and i run the game from the editor, the game randomly crashes after few seconds when triggering input via keyboard or mouse. Disconnecting the gamepad from pc solves the problem.

Trace log doesn't show any interesting stuff, these are few input records from terminal before crashing

Gd::drop   <godot_core::gen::classes::input::re_export::Input>
Gd::drop   <godot_core::gen::classes::input_event::re_export::InputEvent>
  Stat::dec   <godot_core::gen::classes::input_event::re_export::InputEvent>
  +-- was last=false
ptrcall: input
Gd::drop   <godot_core::gen::classes::input::re_export::Input>
Gd::drop   <godot_core::gen::classes::input_event::re_export::InputEvent>
  Stat::dec   <godot_core::gen::classes::input_event::re_export::InputEvent>
  +-- was last=false

The crash itself looks like so:

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.dev1.official (db1302637023168f7becceb1c4ce13228e1b2a43)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f91fee42520] (??:0)
[2] /home/bonsai/GameDev/godot/godot4() [0x468ca27] (??:0)
[3] /home/bonsai/GameDev/godot/godot4() [0x45dbc1c] (??:0)
[4] /home/bonsai/GameDev/godot/godot4() [0x43a9493] (??:0)
[5] /home/bonsai/GameDev/godot/godot4() [0xe59641] (??:0)
[6] /home/bonsai/GameDev/godot/godot4() [0xe5df5a] (??:0)
[7] /home/bonsai/GameDev/godot/godot4() [0xde4090] (??:0)
[8] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f91fee29d90] (??:0)
[9] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f91fee29e40] (??:0)
[10] /home/bonsai/GameDev/godot/godot4() [0xdf1f7e] (??:0)
-- END OF BACKTRACE --

The problem doesnt seem to happen when i

  • disconnect gamepad from pc
  • not using mouse or keyboard while gamepad connected (i can press anything on the gamepad tho)

@lilizoey suggested using std::mem::forget(event) at the end of the input method, which seems to solve the problem aswell. This little amnesia allows me to run the game without any issue. That led to the conclusion, that it might be wrong handling of a reference count

Ive been also asked to reference the issue #204 as it might be related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugc: ffiLow-level components and interaction with GDExtension APIubUndefined behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions