### Godot version

2992ffd25523cb8b3e0ef1b873c40115b8940178

### System information

Windows 10

### Issue description

Godot crashes randomly within a few seconds after project start when moving with the mouse.

![win_err](https://github.com/godotengine/godot/assets/52464204/1da28596-d95b-40f3-b32f-12219ec02c5d)

Started after recent merge of https://github.com/godotengine/godot/pull/67791.
I can confirm that reverting the pr fixes the crashes.

### Steps to reproduce

see desc

### Minimal reproduction project

N/A
Size2i max_window_size = RS::get_singleton()->get_maximum_viewport_size();
	if (max_window_size != Size2i()) {
		return p_limit_size.clamp(Vector2i(), max_window_size);
	} else {
		return p_limit_size.max(Vector2i());
	}
}
void Window::_validate_limit_size() {
	
	bool max_size_valid = (max_size.x > 0 || max_size.y > 0) && max_size.x >= min_size.x && max_size.y >= min_size.y;
	max_size_used = max_size_valid ? max_size : RS::get_singleton()->get_maximum_viewport_size();
}
void Window::set_max_size(const Size2i &p_max_size) {
	ERR_MAIN_THREAD_GUARD;
	Size2i max_size_clamped = _clamp_limit_size(p_max_size);
	if (max_size == max_size_clamped) {
		return;
	}
	max_size = max_size_clamped;
	_validate_limit_size();
	_update_window_size();
}
Size2i Window::get_max_size() const {
	ERR_READ_THREAD_GUARD_V(Size2i());
	return max_size;
}
void Window::set_min_size(const Size2i &p_min_size) {