From a34a6de0b9f6adef67190c862bba971afd5456f5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Dec 2015 14:44:26 -0800 Subject: Fix crash in a non-debug build with assertions enabled QV4::Heap::Base::setVtable has a Q_ASSERT on the state of Base::mm_data, but that member is never initialized anywhere (that is, the Base class does not properly protect its invariant). There were workarounds in some places for initializing the member, but only in debug mode. That was wrong for a number of reasons: 1) Q_ASSERT is still enabled if QT_FORCE_ASSERTS is defined 2) in release mode, the compiler will remove the double initialization anyway Another solution would be to give QV4::Heap::Base a constructor that initializes the member, but I am not sure whether adding a constructor to this class is permitted. Task-number: QTBUG-49681 Change-Id: Ic90fe6b1cbe84978a02fffff141beacbe73c0b9c Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index be09a58fc9..1194033872 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -522,9 +522,7 @@ ReturnedValue SimpleScriptFunction::construct(const Managed *that, CallData *cal callData->thisObject = v4->newObject(ic, proto); CallContext::Data ctx(v4); -#ifndef QT_NO_DEBUG - ctx.mm_data = 0; // make sure we don't run into the assertion in setVTable when allocating a context on the stack -#endif + ctx.mm_data = 0; ctx.setVtable(CallContext::staticVTable()); ctx.strictMode = f->strictMode(); ctx.callData = callData; @@ -561,9 +559,7 @@ ReturnedValue SimpleScriptFunction::call(const Managed *that, CallData *callData Scoped f(scope, static_cast(that)); CallContext::Data ctx(v4); -#ifndef QT_NO_DEBUG - ctx.mm_data = 0; // make sure we don't run into the assertion in setVTable when allocating a context on the stack -#endif + ctx.mm_data = 0; ctx.setVtable(CallContext::staticVTable()); ctx.strictMode = f->strictMode(); ctx.callData = callData; @@ -621,9 +617,7 @@ ReturnedValue BuiltinFunction::call(const Managed *that, CallData *callData) ExecutionContextSaver ctxSaver(scope); CallContext::Data ctx(v4); -#ifndef QT_NO_DEBUG - ctx.mm_data = 0; // make sure we don't run into the assertion in setVTable when allocating a context on the stack -#endif + ctx.mm_data = 0; ctx.setVtable(CallContext::staticVTable()); ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; @@ -645,9 +639,7 @@ ReturnedValue IndexedBuiltinFunction::call(const Managed *that, CallData *callDa ExecutionContextSaver ctxSaver(scope); CallContext::Data ctx(v4); -#ifndef QT_NO_DEBUG - ctx.mm_data = 0; // make sure we don't run into the assertion in setVTable when allocating a context on the stack -#endif + ctx.mm_data = 0; ctx.setVtable(CallContext::staticVTable()); ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; -- cgit v1.2.3