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

uint64_t tick = OS::get_singleton()->get_ticks_usec();
	uint32_t tdiff = tick - last_tick;
	float delta_t = tdiff / 1000000.0;
	last_tick = tick;
	if (delta_t > max_ref_frame) {
		
		velocity = Vector2();
		accum = p_delta_p;
		accum_t = 0;
		return;
	}
	accum += p_delta_p;
	accum_t += delta_t;
	if (accum_t < min_ref_frame) {
		
		return;
	}
	velocity = accum / accum_t;
	accum = Vector2();
	accum_t = 0;
}
void Input::VelocityTrack::reset() {