Closed Bug 939970 Opened 11 years ago Closed 10 years ago

1000s of Xpath ancestor calls consume all memory

Categories

(Core :: XML, defect)

25 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: todd.macculloch, Assigned: peterv)

Details

Attachments

(2 files)

Attached file ff-xpath.zip
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0 (Beta/Release)
Build ID: 20131112160018

Steps to reproduce:

There are two files in the zip archive: and html page with js code and a sample xml document.

1. Copy the attached html file to a webserver (I used Apache 2.4)

2. Open the webpage using firefox, e.g., http://myserver/xpath.html

3. Paste in a sample document into the text area. I use the attached simple-acme-no-text.xml

4. Open FF console (Ctrl-Shift-J)

5. Press the "load the document as xml" button - the console confirms it loaded

6. Press the "find reference nodes" button - the console lists the number found. 3371 for the sample document.

7. Press the "process reference nodes" button. Without a max setting this will try to process all nodes. 




Actual results:

Firefox shows the crash dialog. Send results: Here's one:
https://crash-stats.mozilla.com/report/index/b3b66359-72b4-4cd5-a960-942e22131118

While playing with the processing limits I saw the following in the console:

[Exception... "'out of memory' when calling method: [nsIObserver::observe]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"  location: "native frame :: <unknown filename> :: <TOP_LEVEL> :: line 0"  data: no]



Expected results:

Processed all the nodes without exhausting memory.
Firefox on linux and Waterfox (windows 64bit) can both process the nodes.

IE (9-11) and Chrome (31) both can process the nodes
Flags: needinfo?(jonas)
Attachment #8334038 - Attachment mime type: application/zip → application/jar
Attachment #8334038 - Attachment mime type: application/jar → application/zip
Peter, could you take a look at this one?
Flags: needinfo?(jonas)
Attached patch v1Splinter Review
There's no reason to convert every result to every result type, the getters throw if you ask for a different result type than what was asked when evaluating. In the testcase we're converting the root node to a string and a number for every node in the document, which takes a long time and a lot of memory (we're serializing the whole doc).
Assignee: nobody → peterv
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8340983 - Flags: review?(jonas)
Flags: needinfo?(peterv)
https://hg.mozilla.org/mozilla-central/rev/2b07117dcd7c
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: