### 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)

last_tick = OS::get_singleton()->get_ticks_usec();
	velocity = Vector2();
	accum = Vector2();
	accum_t = 0;
}
Input::VelocityTrack::VelocityTrack() {
	min_ref_frame = 0.1;
	max_ref_frame = 3.0;
	reset();
}
bool Input::is_anything_pressed() const {
	_THREAD_SAFE_METHOD_
	if (!keys_pressed.is_empty() || !joy_buttons_pressed.is_empty() || !mouse_button_mask.is_empty()) {
		return true;
	}
	for (const KeyValue<StringName, Input::Action> &E : action_state) {
		if (E.value.pressed) {
			return true;
		}
	}
	return false;
}
bool Input::is_key_pressed(Key p_keycode) const {