Skip to content

glx: Fix closing of displays associated with xlib_renderer

George Matsumura requested to merge gmmatsumura01/cogl:closedisplay into cogl-1.22

This makes the xlib_renderer associated with a given CoglRenderer a struct member instead of a user data object on such renderer. This is so it can be ensured that the display associated with the xlib renderer can be closed before the xlib renderer object is freed. Otherwise, the default CoglObject behaviour of all user data objects being destroyed before the main object is destroyed is taken, making it so that the display does not get closed. This causes problems with applications that routinely destroy and create multiple contexts, where the number of displays left open can quickly exhaust the X server's maxiumum number of clients.

The reason why this was not triggered more widely is because before commit ed0d2913, the display id was being read from freed memory, even after the user data object (the xlib_renderer) was supposed to be invalid. After ed0d2913, the display is set to NULL during xlib_renderer destruction to avoid misuse, so the platform renderer destructor cannot and does not close the display.

If you think there might be a better method of ensuring that the display is closed before the platform renderer is destroyed, please let me know. I do not have much experience in contributing to open source projects, so I would also greatly appreciate knowing if there is anything I could do better in respect to contribution procedure.

Thank you for your time, and I would be grateful for any reply.

Merge request reports