GLContext: if creating a context fails, deleting it causes crash

Bug #1580118 reported by Gerry Boland
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
qtubuntu (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

See here:
http://paste.ubuntu.com/16343869/

this is the relevant code from qsgthreadedrendererloop.cpp:

        if (!w->thread->gl) {
            w->thread->gl = new QOpenGLContext();
            if (qt_gl_global_share_context())
                w->thread->gl->setShareContext(qt_gl_global_share_context());
            w->thread->gl->setFormat(w->window->requestedFormat());
            w->thread->gl->setScreen(w->window->screen());
            if (!w->thread->gl->create()) {
                const bool isEs = w->thread->gl->isOpenGLES();
                delete w->thread->gl;
                w->thread->gl = 0;
                handleContextCreationFailure(w->window, isEs);
                return;
            }

Qt is creating a GL context object, but creation fails. In cleaning up, QtUbuntu crashes as it's tries to release an invalid context.

Revision history for this message
Albert Astals Cid (aacid) wrote :

FWIW

(gdb) print mEglDisplay
$1 = (EGLDisplay) 0x9de8ad8
(gdb) print mEglContext
$2 = (EGLContext) 0x0

Revision history for this message
Albert Astals Cid (aacid) wrote :

Interestingly we have
    Q_ASSERT(mEglContext != EGL_NO_CONTEXT);
in the constructor of UbuntuOpenGLContext, and
    ./EGL/egl.h:98:#define EGL_NO_CONTEXT ((EGLContext)0)

but since it's a Q_ASSERT and not an ASSERT is not crashing there

Revision history for this message
Gerry Boland (gerboland) wrote :

True. We also shouldn't even try to call eglDestroyContext on a null context.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I was thinking the same thing in bug 1549455. Shouldn't this just be a qtubuntu task under bug 1549455 instead?

Revision history for this message
Gerry Boland (gerboland) wrote :

@vanvugt I wish it were, this is a fairly simple "don'd delete something that wasn't created" issue. Bug 1549455 is a bigger problem, it seems qt is unable to choose a good egl config to render at. More details given there.

Revision history for this message
Emanuele Antonio Faraone (emanueleant03) wrote :

And now?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Michał Sawicz (saviq)
affects: qtubuntu → qtubuntu (Ubuntu)
Changed in qtubuntu (Ubuntu):
status: New → Confirmed
Changed in qtubuntu (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.