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 <crash> I am using latest Mesa git with the i965 driver.
Created attachment 93444 [details] [review] Potential fix
Can you send the patch for review to Mesa mailing list?
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.