Some code in Xext/sync.c need to be fixed, because it can hang the whole GUI.
Well, it is probably very old issue, but IMHO, it need to be fixed, because it can cause freeze of the whole GUI when someone put in the counter value big enough. And with 64 bit values, it is very easy.
Here: https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/Xext/sync.c#L573
The cycle under this line can run almost infinitely if someone intentionally (DoS) or because of some bug (my case), set the counter value to some very big number.
I have researched this problem while trying to fix a bug with _NET_WM_SYNC_REQUEST
processing that freeze the whole GUI.
You can read the whole story in the xfwm4 issue tracker: https://gitlab.xfce.org/xfce/xfwm4/-/issues/625
But in the window manager, only a work-around can be provided. The actual fix should be in the Xorg code.
IMHO, the delta
trigger argument is redundant. The actual value that need to be set into the trigger.wait_value
can be computed by the counter value, trigger.test_type
and (maybe) trigger.event_threshold
.
Something like: wait_value = counter_value + delta
(delta is negative for the negative test_type values)
But of course, all this can be much more complex. I simply can't understand why such functionality was made by iterating through all values in a cycle that potentially can run to infinity.