🌐 AI搜索 & 代理 主页
Skip to content

$.map() fails with large arrays in Сhrome #4320

@fantaclaus

Description

@fantaclaus

When a large array is passed as an argument to $.map() we get an error:

RangeError: Maximum call stack size exceeded

Tested on Chrome 72 for Windows.
JQuery version: 3.3.1

Sample code:

$.map(new Array(300000), i => 1)

Internally it calls to concat.apply and crashes there.

As long as I understand, apply tries to push all elements of the array into the stack before invoking the function concat and fails on stack shortage.

I believe that any function being invoked thru apply with a large array as an argument will fail.

I've found about 14 usages of apply in the code of jQuery. I would suggest you to check out all of these cases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions