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

OS::get_singleton()->vibrate_handheld(p_duration_ms);
}
void Input::set_gravity(const Vector3 &p_gravity) {
	_THREAD_SAFE_METHOD_
	gravity = p_gravity;
}
void Input::set_accelerometer(const Vector3 &p_accel) {
	_THREAD_SAFE_METHOD_
	accelerometer = p_accel;
}
void Input::set_magnetometer(const Vector3 &p_magnetometer) {
	_THREAD_SAFE_METHOD_
	magnetometer = p_magnetometer;
}
void Input::set_gyroscope(const Vector3 &p_gyroscope) {
	_THREAD_SAFE_METHOD_
	gyroscope = p_gyroscope;
}
void Input::set_mouse_position(const Point2 &p_posf) {
	mouse_pos = p_posf;
}
Point2 Input::get_mouse_position() const {
	return mouse_pos;
}
Point2 Input::get_last_mouse_velocity() {
	mouse_velocity_track.update(Vector2());
	return mouse_velocity_track.velocity;
}
BitField<MouseButtonMask> Input::get_mouse_button_mask() const {