Bug 101556

Summary: [llvmpipe] crashes when GL context is created and a previous context was shared
Product: Mesa Reporter: Florian Link <florianlink>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium    
Version: 17.1   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Screenshot of the crash, fence pointer is NULL.

Description Florian Link 2017-06-22 09:27:29 UTC
Created attachment 132131 [details]
Screenshot of the crash, fence pointer is NULL.

I built the current 17.1.3 release on Windows Visual Studio 2015 with LLVM 3.9 (and 4.0 as well).

When I start my Qt application, which creates some GL contexts, I get the crash that you can see in the attached images, when one of the contexts is created.

I tracked the crash down to the following commit (4 month ago):

https://github.com/mesa3d/mesa/commit/043883647acaee0b2c67c1c6b496404ebb4e8d67

As you can see in my screenshot, the fence pointer is NULL and it is not checked before calling a function that needs a valid fence pointer.

It seems to happen when wglMakeCurrent(NULL,NULL) is called by Qt and the context that was active before is a shared context, so the bad fence call happens.
Comment 1 Florian Link 2017-06-22 09:38:35 UTC
I reverted the commit from 

https://github.com/mesa3d/mesa/commit/043883647acaee0b2c67c1c6b496404ebb4e8d67

and then the crash is gone. The problem seems to be: 

stw_context.c: line 442:
         if (old_ctx->shared) {
            struct pipe_fence_handle *fence = NULL;
            old_ctx->st->flush(old_ctx->st,
                               ST_FLUSH_FRONT | ST_FLUSH_WAIT, &fence);
         }
         else {
            old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL);
         }

if I change that back to just:

            old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL);

then the crash is gone. Since the fence pointer points to NULL and stays NULL, the old_ctx->st->flush crashes.
Comment 2 Florian Link 2018-01-29 07:26:01 UTC
This is a duplicate of bug 102148, which has been fixed.

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.