Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

[].push.apply([], a) results in "Out of stack space" #521

@alexlamsl

Description

@alexlamsl
  • Version: 8.11.1
  • Platform: Windows 10 x64

test.js

var a = [];
for (var i = 65536; --i >= 0;) a.push(i);
[].push.apply([], a);

node runs to completion, whereas node-chakracore fails with:

$ node test.js
test.js:3
[].push.apply([], a);
^

Error: Out of stack space
   at Anonymous function (test.js:3:1)
   at Module.prototype._compile (module.js:652:5)
   at Module._extensions[.js] (module.js:663:3)
   at Module.prototype.load (module.js:565:3)
   at tryModuleLoad (module.js:505:5)
   at Module._load (module.js:497:3)
   at Module.runMain (module.js:693:3)
   at startup (bootstrap_node.js:189:9)
   at Anonymous function (bootstrap_node.js:613:3)

I have observed failures with shorter lengths than 65536, but they are not as reliably reproducible. While I appreciate this is a lot of parameters to pass on to Function.apply(), it is an efficient way to construct a large array, e.g. https://github.com/mishoo/UglifyJS2/blob/b5bab254ce2122a43e9ca0fdc757aecda7191576/test/mocha/parentheses.js#L93-L95

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions