function f() { f() }
let count = 0
Error.prepareStackTrace = () => count++
try {
f()
} catch (e) {
// ignore
}
print(count) // prints ~157, increases with bigger --stack-size
It's due to the build_backtrace call in JS_CallInternal that's called every time a stack frame is unwound.
Another way of demonstrating the issue:
function f(n) {
if (--n > 0) f(n)
else throw Error("unwind")
}
Error.prepareStackTrace = (exc, stk) => print(stk.length)
try {
f(16)
} catch (e) {
// ignore
}
Prints:
10
10
10
10
10
10
10
10
10
9
8
7
6
5
4
3
2
1
It's due to the build_backtrace call in JS_CallInternal that's called every time a stack frame is unwound.
Another way of demonstrating the issue:
Prints: