Skip to content
  • Steinar H. Gunderson's avatar
    mesa: Fix locking of GLsync objects. · feb53912
    Steinar H. Gunderson authored and Marek Olšák's avatar Marek Olšák committed
    
    
    GLsync objects had a race condition when used from multiple threads
    (which is the main point of the extension, really); it could be
    validated as a sync object at the beginning of the function, and then
    deleted by another thread before use, causing crashes. Fix this by
    changing all casts from GLsync to struct gl_sync_object to a new
    function _mesa_get_and_ref_sync() that validates and increases
    the refcount.
    
    In a similar vein, validation itself uses _mesa_set_search(), which
    requires synchronization -- it was called without a mutex held, causing
    spurious error returns and other issues. Since _mesa_get_and_ref_sync()
    now takes the shared context mutex, this problem is also resolved.
    
    Fixes bug #92757, found while developing Nageru, my live video mixer
    (due for release at FOSDEM 2016).
    
    v2: Marek: silence warnings, fix declaration after code
    
    Signed-off-by: default avatarSteinar H. Gunderson <sesse@google.com>
    Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
    Signed-off-by: default avatarMarek Olšák <marek.olsak@amd.com>
    feb53912