Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCall to glDeleteFramebuffers happens from wrong OS thread ⇒ crash on exit #879
Comments
|
Sounds like we need to add MakeCurrent() to the drop logic. |
|
Or better yet, the Skia destructor should call MakeCurrent so we can't get this wrong. I'm not super satisfied with how MakeCurrent() works in general. It's too easy to get wrong right now. |
|
When I patch Skia like so: diff --git a/src/gpu/gl/unix/SkNativeSharedGLContext_unix.cpp b/src/gpu/gl/unix/SkNativeSharedGLContext_unix.cpp
index d7dd097..2ce48f5 100644
--- a/src/gpu/gl/unix/SkNativeSharedGLContext_unix.cpp
+++ b/src/gpu/gl/unix/SkNativeSharedGLContext_unix.cpp
@@ -33,6 +33,7 @@ SkNativeSharedGLContext::SkNativeSharedGLContext(GrGLSharedContext sharedContext
SkNativeSharedGLContext::~SkNativeSharedGLContext() {
if (fGL) {
+ glXMakeCurrent(fDisplay, fGlxPixmap, fContext);
SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO));
SK_GL_NOERRCHECK(*this, DeleteTextures(1, &fTextureID));
SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID));the segfaults are replaced by
So we'll have to do something more. |
|
That goes away if I preserve the GLFW window (in addition to the library global state) through program exit. |
|
I think it might be right to call glXMakeCurrent here anyway, even if it doesn't solve this problem. |
|
Yeah, I think it is the right solution, we just need to keep the window alive too (which is an extension of the fix for #822) |
|
Did we fix this? |
|
Yes, this is fixed by the sweeping changes in #1487 |
Sometimes (about half the time) the last reference to the Skia GL context is dropped from an OS thread that doesn't have the OpenGL thread-local state, causing a crash on exit. Here's a GDB transcript showing how this happens.
We are making OpenGL calls from the thread with Id = 2. The "Target Id" is equal to that thread's
%fsregister value, used for thread-local storage.Let's examine a particular bit of TLS (offset justified below):
The current thread (Id = 2) has a non-null value here, pointing to data within
libnvidia-glcore.so.304.88, while thread 3 hasNULL.Servo displays the page. Now we close the window.
We are on thread 3, trying to call
glDeleteFramebuffersthrough thatNULLpointer from TLS. The offset from%fsis the one we examined earlier.Note that I had to apply this patch first:
to avoid another crash on exit (#822).