Array.join() on long array hangs browser for unreasonably long time

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
14 years ago
12 years ago

People

(Reporter: Thomas Fach-Pedersen, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040707 Firefox/0.9.2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040707 Firefox/0.9.2

Doing

var a = Array(); a[3000000000] = 1; alert(a.join(", "));

hangs Firefox at 95%+ cpu. It eat memory pretty slowly so it doesn't OOM in a
timeframe I've been willing to endure.

Reproducible: Always
Steps to Reproduce:
1. Go to http://www.madmoose.dk/array-join-lockish.html
2. Wait
3. Wait some more


Actual Results:  
Firefox locked up

Expected Results:  
IE says "Out of memory at line: 4" immediately. It probably detects beforehand
that it doesn't have the memory to complete the join.
-> shaver
Assignee: general → shaver
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 2

14 years ago
This is going to be running for a very long time.  Is it reasonable to malloc
all the space for the separators up front and then realloc by the string size? 
That would weed out some of the more bogus calls quickly.

Updated

12 years ago
Blocks: 334935

Updated

12 years ago
Depends on: 310405
Mass abdication.
Assignee: shaver → nobody

Comment 4

12 years ago
The patch for bug 310405 addresses this.
Status: NEW → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.