display_fatal_error set if wl_closure_send fails with EAGAIN
It was noticed that if a client misbehaves (sends thousands of requests in a row without flushing), the libwayland library may set a fatal display error.
The flow is the following -
a client's call -> wl_proxy_marshal_array_constructor_versioned -> wl_closure_send -> wl_connection_write.
The wl_connection_write may call wl_connection_flush[1] inside, which may return -1 and set EAGAIN. However, wl_closure_send will set display_fatal_error[2], which means looking for an fd to be writable again is useless as wl_display_flush[3] never executes and always returns the last_error code, which doesn't seem to be possible to remove. Moreover, if a client checks for errors on the display through the wl_display_get_error call, it'll see that error and stop (as the spec suggests) as errors from wl_display_get_error are fatal [4].
Is that an expected behaviour?
[1] https://gitlab.freedesktop.org/wayland/wayland/-/blob/main/src/connection.c#L379
[2] https://gitlab.freedesktop.org/wayland/wayland/-/blob/main/src/wayland-client.c#L861
[3] https://gitlab.freedesktop.org/wayland/wayland/-/blob/main/src/wayland-client.c#L2147