Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#6796 closed bug (fixed)

Error 'script stack space quota is exhausted' when parsing 3MB XML file on Firefox

Reported by: petewarden Owned by: petewarden
Priority: undecided Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: xml firefox Cc:
Blocked by: Blocking:


I'm running into 'script stack space quota is exhausted' when loading a 3.4MB XML file using JQuery, and have created a minimal example that reproduces the problem at http://firefox-stack-bug.s3.amazonaws.com/index.html

Steps to Reproduce: 1 - Open http://firefox-stack-bug.s3.amazonaws.com/index.html in Firefox 2 - After a few seconds check the error console

Actual Results: The code fails with the message

Error: script stack space quota is exhausted Source File: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js Line: 21

Expected Results: The XML file should be loaded and parsed

The same page runs with no problems in Safari 5.0 and Chrome 6.0. My full Firefox version is

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20100625 Firefox/3.6.6

You can download a zip of the source files at http://web.mailana.com/labs/firefox_stack_bug.zip

I've filed the following bug with the Firefox team since there's no problem when running on other platforms, but since it's JQuery code that's causing the error I'm filing one here too, in case there's a fix I could use in the framework, rather than waiting for a Mozilla patch.


Change History (10)

comment:1 Changed 13 years ago by petewarden

I've just tried it on IE 8, and the test page runs successfully, if slowly, so it appears to be a Firefox-specific issue.

comment:2 Changed 13 years ago by dmethvin

Component: unfiledcore

It looks like you're trying to parse an XML string with $() and that's not supported. Only HTML strings can be passed. If I've interpreted the test case incorrectly, reply with an explanation of what's going on.

Firefox seems to be dying on the constructor check for HTML, which uses a RegExp:

match = quickExpr.exec( selector );

The string you're passing in is long and html-ish, and I suspect Firefox is backtracking heavily trying to match the huge string. We can either assume a long (>1K chars) string must be HTML or come up with a RegExp that doesn't need to backtrack so much.

comment:3 Changed 13 years ago by petewarden

Should I move this to the documentation component then? It looks like I'm not the only one who mistakenly thinks XML parsing is supported, see these tutorials listed on the main JQuery site at http://docs.jquery.com/Tutorials:

http://marcgrabanski.com/articles/jquery-makes-parsing-xml-easy http://www.xml.com/pub/a/2007/10/10/jquery-and-xml.html

The only documentation I can find by doing a Google query of 'site:jquery.com xml parsing not supported' is this forum thread mentioning it at the end. http://forum.jquery.com/topic/what-is-the-status-of-jquery%E2%80%99s-multi-argument-content-syntax-deprecated-supported-documented

comment:4 Changed 12 years ago by ridgerunner

This bug may now be fixed. The recent Regex improvements (see #7062) included a change to the quickExpr regex which dramatically reduced the backtracking it required for the case of non-matches.

comment:5 Changed 12 years ago by uwgandalf

I checked out the newest version from git, and I still have the same problems as the TS. @ridgerunner: Were the changes committed to git, or were you talking about a non-git patch to reduce the backtracking?

comment:6 Changed 12 years ago by addyosmani

Priority: undecided

Can anyone confirm for sure whether this issue is still being experienced using the new 1.4.3 RC2?

comment:7 Changed 12 years ago by snover

Owner: set to petewarden
Status: newpending

Please confirm whether or not this issue still occurs with jQuery 1.4.3. Thank you!

comment:8 Changed 12 years ago by petewarden

Status: pendingnew

I've confirmed that the problem doesn't occur with 1.4.3, so this bug can be closed

comment:9 Changed 12 years ago by snover

Resolution: fixed
Status: newclosed

comment:10 Changed 12 years ago by [email protected]

The low limit still exists in Firefox. Given this, I think dmethvin's suggestion to assume anything over 1K is HTML is reasonable.

In my case, I'm using the jstree plugin which is taking a rather large XML document and using XSLT to turn it to a string containing an HTML nested list, which it then passes to jQuery's constructor to create DOM objects. I get the "stack quota" error in the same RegExp call mentioned in this ticket.

To reproduce, open http://jsfiddle.net/6GvyJ/ with Firefox (in my case 3.6.13) with Firebug enabled. The script simply dynamically creates a large string containing the html for an unordered list. I've tweaked the len variable to be right over the edge of Firefox's limit. Set len to 71859 and the script will work.

In Chrome, I was able to set len to several hundred thousand before I started having issues.

Note: See TracTickets for help on using tickets.