Closed Bug 1825675 Opened 2 years ago Closed 2 years ago

Flattening rope with multiple references to an initial string leaves part of the result uninitialized

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: sfink, Assigned: sfink)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

If you do:

     s = ...;
     r = newRope(s, newRope(s, "!"));
     ensureLinearString(r);

where s is an extensible string with capacity >= s.length * 2 + 1, then the resulting flattened string will have a s-sized chunk of uninitialized characters in it.

Currently this bug appears to be unreachable: the only way to create an extensible string is via flattening, which sets the capacity to at most the needed length rounded up to the next power of 2. Hitting this bug requires the string to appear more than once in the DAG, the minimum length of rope required is s.length * 2.

The most "extra" space there will ever be in an extensible string is when its length is 1 more than a power of 2, so the extra space will be just less than its length, and the total capacity is less than s.length * 2.

However, there are a couple of changes I have experimented with that produce extensible strings in more situations and with more possible capacities. (It's how I ran into it; I was adding an extra 3 bytes to extensible strings' capacities.)

Includes a test using a new option to the newString() testing function: newString("...", { capacity: 1000 }) will create an extensible string with 1000-character capacity.

Assignee: nobody → sphink
Status: NEW → ASSIGNED
Blocks: 1815266
Severity: -- → S3
Priority: -- → P1
Pushed by sfink@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7944153dd2d1 Fix string flattening when reusing an extensible string buffer that appears at more than one place in the DAG. r=jandem
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
Regressions: 1827072
Blocks: 1848884
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: