[cairo-bugs] [Bug 91967] Assertion "(_cairo_atomic_int_get (&(&surface->ref_count)->ref_count) > 0)"

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Jun 19 09:38:15 UTC 2016


https://bugs.freedesktop.org/show_bug.cgi?id=91967

Uli Schlachter <psychon at znc.in> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
           Assignee|chris at chris-wilson.co.uk    |psychon at znc.in

--- Comment #45 from Uli Schlachter <psychon at znc.in> ---
commit d69dd6b341594c338fa6c7b327fd7f201eb37bc1
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Jun 18 15:08:52 2016 +0200

    xlib: Fix double free in _get_image_surface()

    If XShmGetImage() fails, the code tries to continue with its normal,
    non-shared-memory path. However, the image variable, which was previously
set to
    NULL, now points to an already-destroyed surface, causing a double-free
when the
    function cleans up after itself (actually, its an assertion failure because
the
    reference count of the surface is zero, but technically this is still a
double
    free).

    Fix this by setting image=NULL after destroying the surface that this
refers to,
    to make sure this surface will not be destroyed again.

    While we are here (multiple changes in a single commit are bad...), also
fix the
    cleanup done in bail. In practice, &image->base should be safe when
image==NULL,
    because this just adds some offset to the pointer (the offset here is
actually
    zero, so this doesn't do anything at all). However, the C standard does not
    require this to be safe, so let's handle this case specially.

    Note that anything that is fixed by this change is still buggy, because the
only
    reason why XShmGetImage() could fail would be BadDrawable, meaning that the
    target we draw to does not exist or was already destroyed. This patch will
    likely just cause X11 errors elsewhere and drawing to (possible) invalid
    drawables is not supported by cairo anyway. This means that if SHM fails,
the
    following fallback code has a high chance of failing, too.

    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91967
    Signed-off-by: Uli Schlachter <psychon at znc.in>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo-bugs/attachments/20160619/376fc444/attachment-0001.html>


More information about the cairo-bugs mailing list