### 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
_THREAD_SAFE_METHOD_
	p_screen = _get_screen_index(p_screen);
	ERR_FAIL_INDEX_V(p_screen, get_screen_count(), SCREEN_REFRESH_RATE_FALLBACK);
	
	if (xrandr_ext_ok) {
		XRRScreenResources *screen_info = XRRGetScreenResources(x11_display, windows[MAIN_WINDOW_ID].x11_window);
		if (screen_info) {
			RRMode current_mode = 0;
			xrr_monitor_info *monitors = nullptr;
			if (xrr_get_monitors) {
				int count = 0;
				monitors = xrr_get_monitors(x11_display, windows[MAIN_WINDOW_ID].x11_window, true, &count);
				ERR_FAIL_INDEX_V(p_screen, count, SCREEN_REFRESH_RATE_FALLBACK);
			} else {
				ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
				return SCREEN_REFRESH_RATE_FALLBACK;
			}
			bool found_active_mode = false;
			for (int crtc = 0; crtc < screen_info->ncrtc; crtc++) { 
				XRRCrtcInfo *monitor_info = XRRGetCrtcInfo(x11_display, screen_info, screen_info->crtcs[crtc]);