aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-12-01 14:44:26 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-12-29 13:59:13 +0000
commita34a6de0b9f6adef67190c862bba971afd5456f5 (patch)
tree65250d88472738bcb791cc87272111f8cdf50721 /src
parente3942a2fa53113b34b3206f446dae3a638b8331f (diff)
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 <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp16
1 files changed, 4 insertions, 12 deletions
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<SimpleScriptFunction> f(scope, static_cast<const SimpleScriptFunction *>(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;