Better error for extremely long array initialiser

RESOLVED FIXED in mozilla1.8beta2

Status

()

P2
normal
RESOLVED FIXED
14 years ago
14 years ago

People

(Reporter: firefox_bugzilla, Assigned: brendan)

Tracking

({js1.5})

Trunk
mozilla1.8beta2
js1.5
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(2 attachments)

(Reporter)

Description

14 years ago
When loading a page with a JS-array on one line containing about 10MB of data, I
get an error that the array is not "closed" there is a missing "]".

This is not the case, as the screenshot of the error indicates. It seems that
the buffer reading lines from the document is simply not big enough, thus the
array seems unfinished.

I have "shortened" the array in an other file, and then no error occurs.
(Reporter)

Comment 1

14 years ago
Created attachment 169765 [details]
Contains screenshot of error, and two html-files one with the error one without

Updated

14 years ago
Component: JavaScript Console → JavaScript Console
OS: Linux → All
Product: Firefox → Core
Hardware: PC → All

Updated

14 years ago
Component: JavaScript Console → JavaScript Engine
Assignee: bugs → general
QA Contact: firefox.js-console → pschwartau

Comment 2

14 years ago
Created attachment 169809 [details]
testcase

Well, at least using eval() the limit is a lot lower than 10 MB, the script
fails at 196613 characters (6 more than IE6 ;-)).

Warning: the testcase sometimes crashes Firefox/20041229 Win32 for me if the
JavaScript Console is open while it's running. Sorry, no talkback ID, the
talkback agent still can't be installed with this build.

Comment 3

14 years ago
Doh, there is a 64K limit in place here and each of the elements in my testcase
takes 3 characters, that's why I get 196613 (3*65536+5) as the limit. 
Confirming with current trunk.
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 5

14 years ago
IE fails with out of memory on Erik's test case. Brendan, what say you? Thumbs
down-> wontfix?
QA Contact: pschwartau → moz
(Assignee)

Comment 6

14 years ago
I'd like to diagnose this first.

Crazy amounts of data are flowing as/in JS, these days ("Ajax", donchaknow).  If
we can fix this easily, and you have a lot of RAM, why not?

/be
Assignee: general → brendan
(Assignee)

Comment 7

14 years ago
This is because of the 16 bit immediate literal index limit, which I've lifted
with the checkin for bug 155081 to a 24 bit (effectively, 23 bits because of
source note representation) limit.  That ought to be enough!

This bug should be morphed, no matter the limit, to ask for a clear diagnostic
that says what the problem is, instead of making a bogus syntax error out of an
array literal too long to fit in the engine's current bytecode representation.

/be
Status: NEW → ASSIGNED
Keywords: js1.5
Priority: -- → P2
Summary: JS-error on long lines (10MB of data in an array) → Better error for extremely long array initialiser
Target Milestone: --- → mozilla1.8beta2
Version: 1.0 Branch → Trunk
(Assignee)

Comment 8

14 years ago
Fixed; it was obvious and safe for 1.8b2.

/be
Status: ASSIGNED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.