diff options
author | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2016-05-26 17:22:34 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-05-27 10:04:59 +0000 |
commit | dbf7efde1e04ac0ff445f64438078d87eb035b68 (patch) | |
tree | 5b856f1ecccf22ac71ec18c9f2b196f1eec7290d /src | |
parent | cba2ef0a37f1e6972f1eb641c7157f9c69861c13 (diff) |
V4: Mirror jsAlloc behavior at stack allocation.
Allocating from the JS stack will zero out the memory, and thus indicate
to valgrind that memory is not uninitialized. By first marking the whole
stack as uninitialized and only then allocating 2 entries, the behavior
for those two entries will now match the allocation behavior. This
fixes a false positive when using valgrind.
Change-Id: Icdb5279e1cfbfe6b5c385cc42c556edf721fa74b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index fefc5b6308..5dc3e6151f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -170,6 +170,10 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) /* writable */ true, /* executable */ false, /* includesGuardPages */ true); jsStackBase = (Value *)jsStack->base(); +#ifdef V4_USE_VALGRIND + VALGRIND_MAKE_MEM_UNDEFINED(jsStackBase, 2*JSStackLimit); +#endif + jsStackTop = jsStackBase; exceptionValue = jsAlloca(1); @@ -179,10 +183,6 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) typedArrayCtors = static_cast<FunctionObject *>(jsAlloca(NTypedArrayTypes)); jsStrings = jsAlloca(NJSStrings); -#ifdef V4_USE_VALGRIND - VALGRIND_MAKE_MEM_UNDEFINED(jsStackBase, 2*JSStackLimit); -#endif - // set up stack limits jsStackLimit = jsStackBase + JSStackLimit/sizeof(Value); diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index d7fd44e1d6..ca7efb1e79 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -82,7 +82,7 @@ struct Scope { memset(mark, 0, (engine->jsStackTop - mark)*sizeof(Value)); #endif #ifdef V4_USE_VALGRIND - VALGRIND_MAKE_MEM_UNDEFINED(mark, engine->jsStackLimit - mark); + VALGRIND_MAKE_MEM_UNDEFINED(mark, (engine->jsStackLimit - mark) * sizeof(Value)); #endif engine->jsStackTop = mark; } |