Skip to content

cogl-xlib-renderer: Ensure we don't close the same X display twice

Simon McVittie requested to merge wip/smcv/double-close into cogl-1.22

If we don't do this, it results in a double-free that segfaults test_atlas_migration on ES2, when running an x86_64 build under Xvfb (probably other architectures and displays, I haven't checked).

==671783==ERROR: AddressSanitizer: SEGV on unknown address ...
==671783==The signal is caused by a READ memory access.
    #0 0x7fbc0b5a28e7 in xcb_disconnect (...)
    #1 0x7fbc0bfc2be8 in XCloseDisplay (...)
    #2 0x7fbc0d6b8910 in _cogl_xlib_renderer_disconnect .../cogl/cogl-xlib-renderer.c:573
    #3 0x7fbc0d6eba71 in _cogl_winsys_renderer_disconnect .../cogl/winsys/cogl-winsys-egl-x11.c:257
    #4 0x7fbc0d6ebd7e in _cogl_winsys_renderer_connect .../cogl/winsys/cogl-winsys-egl-x11.c:289
    #5 0x7fbc0d55e970 in cogl_renderer_connect .../cogl/cogl-renderer.c:687
    #6 0x7fbc0d557dff in cogl_context_new .../cogl/cogl-context.c:202
    #7 0x7fbc0d6fcce5 in test_utils_init .../test-fixtures/test-utils.c:176
    #8 0x557c76a1c7f5 in main .../tests/conform/test-conform-main.c:90
    #9 0x7fbc0c527bba in __libc_start_main ../csu/libc-start.c:308
    #10 0x557c76a1b209 in _start (...)

With this commit and the rest of my recently-merged MRs, I can successfully run cogl's build-time tests with AddressSanitizer and UndefinedBehaviourSanitizer on Debian unstable x86_64, using Mesa on Intel hardware, on either Xvfb or GNOME Shell + XWayland. Tests with known failures or missing features are skipped (by !15 (merged)), the rest pass, and none crash.

Known issues:

  • There are a bunch of memory leaks. I'm disabling leak detection with ASAN_OPTIONS=detect_leaks=0 because I'm more interested in crashes.
  • Some tests are marked FIXME and skipped (by !15 (merged)), but that isn't a regression.
Edited by Simon McVittie

Merge request reports