aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljsast_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-09-02 14:44:29 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-09-17 10:05:04 +0200
commit873f13164d63cbb7db7d2289fd3e504d7553fb5b (patch)
tree2328ca556fa7f3190fbb32f75899951cf3dd8d90 /src/qml/parser/qqmljsast_p.h
parentd1071eed3f4c72b553903b47a7afca955b62f029 (diff)
V4: Provide an environment variable to disable runtime stack size checks
With QV4_CRASH_ON_STACKOVERFLOW set you can use up all the stack provided by the operating system to parse and execute JavaScript. Once the stack space is exhausted the program crashes like it would in case of a C++ stack overflow. We cannot reliably determine either the maximum stack size or the amount of stack space currently in use at runtime. Therefore, the guards we usually put in place are necessarily conservative. [ChangeLog][QtQml] There is now an option to disable the (necessarily) conservative stack size checks when parsing and executing JavaScript. If the environment variable QV4_CRASH_ON_STACKOVERFLOW is set, JavaScript stack overflows crash the program the same way C++ stack overflows do. On the flip side, more stack space is made available that way. Task-number: QTBUG-74087 Change-Id: I5e9d9ec6c0c9c6258c31d9e2d04a5c1819fbf400 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast_p.h')
-rw-r--r--src/qml/parser/qqmljsast_p.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 4247785905..bdda46da90 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -275,10 +275,16 @@ public:
virtual FunctionExpression *asFunctionDefinition();
virtual ClassExpression *asClassDefinition();
+ bool ignoreRecursionDepth() const;
+
inline void accept(Visitor *visitor)
{
Visitor::RecursionDepthCheck recursionCheck(visitor);
- if (recursionCheck()) {
+
+ // Stack overflow is uncommon, ignoreRecursionDepth() only returns true if
+ // QV4_CRASH_ON_STACKOVERFLOW is set, and ignoreRecursionDepth() needs to be out of line.
+ // Therefore, check for ignoreRecursionDepth() _after_ calling the inline recursionCheck().
+ if (recursionCheck() || ignoreRecursionDepth()) {
if (visitor->preVisit(this))
accept0(visitor);
visitor->postVisit(this);