Race condition in XDamage

Jonathan Lennox lennox at cs.columbia.edu
Thu Feb 3 11:57:10 PST 2005


In some of my experimentation with the damage extension, I've discovered
what appears to be a race condition in the extension definition.

If a damage report level other than DamageReportRawRectangles is chosen,
it's possible for a client which is monitoring the contents of a window to
miss a change to the window.  Here's the flow of events.

("Client" is drawing to a window; "Monitor" is receiving DamageNotify events
with level == DamageReportDeltaRectangles and using XGetImage to update its
private pixmap of the window.)

* Monitor's damage region is empty.
* Client draws to a region R of the window.
* The server sends DamageNotify events to Monitor reporting damages to
  region R.  Monitor's damage region now == R.
* Monitor calls XGetImage on region R.
* Client draws again within region R.  Since the drawing is contained within
  Monitor's existing damage region, no DamageNotify events are sent.
* Monitor calls DamageSubtract on R.

Monitor's copy of the window is now missing Client's second update!  I've
actually observed this happening.

The potential solutions, as far as I can tell, are either to a) always use
raw reports, or b) for Monitor to grab the server before XGetImage and
release it after DamageSubtract.  Is there some other alternative I'm
missing? 

-- 
Jonathan Lennox
lennox at cs.columbia.edu



More information about the xorg mailing list