mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 12:45:25 +00:00

PR-URL: https://github.com/nodejs/node/pull/44741 Fixes: https://github.com/nodejs/node/issues/44650 Fixes: https://github.com/nodejs/node/issues/37472 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --stack-size=100 --no-turbofan
|
|
|
|
function f(
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
|
|
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x
|
|
) { }
|
|
|
|
function runNearStackLimit(f) {
|
|
let recursing_towards_stack_limit = true;
|
|
let f_succeeded = false;
|
|
|
|
function t() {
|
|
try {
|
|
t();
|
|
if (f_succeeded) return;
|
|
// Keep calling f until it stops throwing stack overflow exceptions.
|
|
f();
|
|
// f didn't throw, so we are done.
|
|
f_succeeded = true;
|
|
} catch(e) {
|
|
if (recursing_towards_stack_limit) {
|
|
recursing_towards_stack_limit = false;
|
|
// We reached the near stack limit state, call f first time.
|
|
f();
|
|
// f didn't throw, so we are done.
|
|
f_succeeded = true;
|
|
}
|
|
}
|
|
};
|
|
|
|
try {
|
|
t();
|
|
} catch(e) {}
|
|
}
|
|
|
|
runNearStackLimit(f);
|