Bug Tracker

Modify

Ticket #6796 (closed bug: fixed)

Opened 4 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

Description

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:1.9.2.6) 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.

 https://bugzilla.mozilla.org/show_bug.cgi?id=579656

Change History

comment:1 Changed 4 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 4 years ago by dmethvin

  • Component changed from unfiled to core

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 4 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 4 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 4 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 4 years ago by addyosmani

  • Priority set to undecided

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

comment:7 Changed 4 years ago by snover

  • Owner set to petewarden
  • Status changed from new to pending

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

comment:8 Changed 4 years ago by petewarden

  • Status changed from pending to new

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

comment:9 Changed 4 years ago by snover

  • Status changed from new to closed
  • Resolution set to fixed

comment:10 Changed 3 years ago by elcarpie@…

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.