apitrace/apitrace — pull request #228 by lawlove (2014-02-21 20:07:43+00:00)
Title: qapitrace: issue #218 crashes on glPopDebugGroup

Problem:
dereferencing a NULL pointer.

Reason:
As mentioned in the issue description, a glPushDebugGroup and
glPopDebugGroup pair were in two different frames. The
TraceLoader:fetchFrameContents() function assumes they're in the
same frame and starts a new "groups" stack for each frame fetch.
On encountering a CALL_FLAG_MARKER_POP call, does

groups.top()->finishedAddingChildren();

when in fact groups is empty and is dereferencing a NULL pointer.

In the other sample trace (sample-effects.trace) all glPush/Pop pairs
were in the same frame but one frame had an extra glPopDebugGroup
causing the same error.

Fix:
Add a groups.count() check before dereferencing groups.top()

Caveats:
Any unpaired glPopDebugGroup calls will be listed as regular gl calls.
Any unpaired glPushDebugGroup calls will end with the frame end.

Tested both sample crash traces; they no longer crash.
(apitrace-tests doesn't apply for testing this fix)

Signed-off-by: Lawrence L Love