-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Math.min NOT work with 123021 numbers #36958
Comments
It seems to happen only on REPL and when using eval (E.G.: I can also reproduce using |
This is not a bug, rather a known limitation. See #16870 |
I'm not sure this is exactly the same problem, as it doesn't happen not on DevTools, nor on Node.js executing a file – so it's not a V8 limitation. It seems there's another limitation with REPL and eval, which we may be able to workaround. |
I don't know what you mean exactly. The example code you gave in #36958 (comment) also fails if executed from a file or in Chrome devtools |
I've run the OP code on DevTools (V8 8.7) it outputs the expected result: And on Node.js (V8 8.6) it works only when executing a file rather than eval a string: $ cat math:min.js
function creat_arr(lngth2,lngth3){
let arr_two = Array.from({length:lngth2}).map(r=>2)
let arr_three = Array.from({length:lngth3}).map(r=>3)
let arr = Array.prototype.concat(arr_two,arr_three)
return(arr)
}
var arr = creat_arr(63124,60166)
console.log(Math.min(...arr))
$ node math:min.js
2
$ node < math:min.js
[stdin]:9
console.log(Math.min(...arr))
^
RangeError: Maximum call stack size exceeded
at [stdin]:9:18
at Script.runInThisContext (node:vm:133:18)
at Object.runInThisContext (node:vm:310:38)
at node:internal/process/execution:77:19
at [stdin]-wrapper:6:22
at evalScript (node:internal/process/execution:76:60)
at node:internal/main/eval_stdin:29:5
at ReadStream.<anonymous> (node:internal/process/execution:205:5)
at ReadStream.emit (node:events:376:20)
at endReadableNT (node:internal/streams/readable:1295:12) |
It's probably because depending on the situations, the code stays below your stack size. If you execute the same code with larger arrays you should be able to reproduce everywhere. |
I am closing this as there's nothing that can be done on Node.js side about this. |
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
always, if with too many params
What is the expected behavior?
What do you see instead?
Uncaught RangeError: Maximum call stack size exceeded
at Math.min ()
Additional information
The text was updated successfully, but these errors were encountered: