Fix GC crash with conditional breakpoints and JS console
authorSimon Hausmann <simon.hausmann@theqtcompany.com>
Fri, 19 Dec 2014 11:39:21 +0000 (12:39 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Fri, 19 Dec 2014 15:30:13 +0000 (16:30 +0100)
We may choose to execute an expression in a specific frame within the
debugger, which is where we pop context's until we reached the frame
in question. If we are trying to execute an expression at the top of the
stack (or with a conditional breakpoint expression), then we don't have
a frame and don't need to pop contexts. But also also don't need to call
Scope::alloc(-1).

Change-Id: I1f6754a3d77d943aed9bf4468e817a5269a3c547
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4debugging.cpp

index ca5af36..483d750 100644 (file)
@@ -67,10 +67,12 @@ public:
 
         ExecutionContextSaver saver(scope, engine->currentContext());
 
-        Value *savedContexts = scope.alloc(frameNr);
-        for (int i = 0; i < frameNr; ++i) {
-            savedContexts[i] = engine->currentContext();
-            engine->popContext();
+        if (frameNr > 0) {
+            Value *savedContexts = scope.alloc(frameNr);
+            for (int i = 0; i < frameNr; ++i) {
+                savedContexts[i] = engine->currentContext();
+                engine->popContext();
+            }
         }
 
         ScopedContext ctx(scope, engine->currentContext());