### Godot version

v3.5.stable.official [991bb6ac7]

### System information

Debian 11 - Intel Ivybridge Mobile - GLES3

### Issue description

Pretty much what the title says, the engine freezes when I call Sprite.new() from a method that I previously connected to `joy_connection_changed` signal. No errors are shown.

### Steps to reproduce

1. Run the minimal reproduction project, you will see the Godot icon moving around.
2. Connect or disconnect a gamepad and you will see the icon stops moving due to engine freeze.

### Minimal reproduction project

[minimal-reproduction-project.zip](https://github.com/godotengine/godot/files/11821885/minimal-reproduction-project.zip)

ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action));
	HashMap<StringName, Action>::ConstIterator E = action_state.find(p_action);
	if (!E) {
		return false;
	}
	if (p_exact && E->value.exact == false) {
		return false;
	}
	
	bool released_requirement = legacy_just_pressed_behavior ? !E->value.pressed : true;
	if (Engine::get_singleton()->is_in_physics_frame()) {
		return released_requirement && E->value.released_physics_frame == Engine::get_singleton()->get_physics_frames();
	} else {
		return released_requirement && E->value.released_process_frame == Engine::get_singleton()->get_process_frames();
	}
}
float Input::get_action_strength(const StringName &p_action, bool p_exact) const {