gamma: read(3) race
Gamma ramps are submitted as a file descriptor in the zwlr_gamma_control_v1 protocol. wlroots reads these ramps with read(3)
, relying on and advancing the file description offset.
wlsunset reuses a mapped file for each output, and must lseek(3)
before each use to undo the advanced offset. If provoked to send gamma ramps very fast (such as through a WIP SIGUSR1 toggle), a race occurs where wlsunset submits ramps faster than wlroots consumes them: the file description seek does not align with the completion of the read done by wlroots, resulting in a case where EOF may occur during read. This results in a protocol error, disconnecting wlsunset.
Options:
- Add a 'done' event to zwlr_gamma_control_v1, making it possible for wlsunset et.al. to have strict synchronization.
- Use
pread(3)
ormmap
in wlroots to be position independent (a breaking change, but unlikely to matter much).