Created
November 11, 2024 01:53
-
-
Save dmitry-vsl/c7e309a5008f78f8c47cd45644ed9910 to your computer and use it in GitHub Desktop.
JS intrinsic function can cause stackoverflow (node.js)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let error | |
function stackoverflow() { | |
try { | |
stackoverflow() | |
} catch(e) { | |
try { | |
[1,2,3] // try commenting this line | |
} catch(e) { | |
error = e | |
} | |
} | |
} | |
stackoverflow() | |
/* | |
prints "RangeError: Maximum call stack size exceeded", unless you comment out | |
the line before. It seems that intrinsic function is called for array | |
construction, which causes stackoverflow error | |
*/ | |
console.log(error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment