Bug 74563

Summary: Surfaceless contexts are not properly released by DRI drivers
Product: Mesa Reporter: Alexandros Frantzis <alexandros.frantzis>
Component: EGLAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: chadversary, daniel, kondapallykalyancontribute
Version: git   
Hardware: All   
OS: All   
i915 platform: i915 features:
Attachments: Example that exhibits the issue
Potential fix

Description Alexandros Frantzis 2014-02-05 12:42:40 UTC
Created attachment 93443 [details]
Example that exhibits the issue

Releasing a surfaceless EGL context doesn't properly release the underlying DRI context, sometimes leading to crashes. I have attached an example that exhibits such a crash (run it in a VT).

Without a fix, the example crashes when the main thread tries to make context2 current, because mesa tries to _mesa_flush the invalid (destroyed in the other thread) context1, left as current in the main thread by the previous make current operation (and not cleaned by releasing the egl context).

The problem seems to be that the driUnbindContext() function doesn't call the driver unbind function if the context is surfaceless. Moving the call to the driver function before the drawable validity checks fixes things for me (see attached patch), although I am not familiar enough with that code to be confident that this is indeed the right approach.

Note the absence of _mesa_make_current() calls for context releases in the logs:

# MESA_VERBOSE=api ./mesa_surfaceless_context_crash
T1: Make current 1
Mesa: _mesa_make_current()
T1: Release current 1
T1: after Release current 1
Main: Make current 1
Mesa: _mesa_make_current()
Main: Release current 1
Main: after Release current 1
Mesa: _mesa_make_current()
Mesa: glDeleteObjectARB(0)
Mesa: glDeleteObjectARB(0)
Mesa: glDeleteTextures 1
Mesa: _mesa_make_current()
Mesa: _mesa_make_current()
Main: Make current 2

I am using latest Mesa git with the i965 driver.
Comment 1 Alexandros Frantzis 2014-02-05 12:46:02 UTC
Created attachment 93444 [details] [review]
Potential fix
Comment 2 kalyank 2014-10-20 09:41:36 UTC
Can you send the patch for review to Mesa mailing list?
Comment 3 Tapani Pälli 2014-11-06 11:57:52 UTC
was pushed to master

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.