Closed Bug 1197097 Opened 9 years ago Closed 9 years ago

JSON.stringify should not use context-wide auto-cycle detection

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: anba, Assigned: Waldo)

References

Details

Attachments

(1 file)

Test case 1:
---
a = [{}];
JSON.stringify(a, function(k, v){
  JSON.stringify(a);
  return v;
});
---

Test case 2:
---
a = [{
  toString: () => JSON.stringify(a)
}];
a.join();
---


Expected: Both tests return "[{}]"
Actual: Throws `TypeError: cyclic object value`
Attached patch PatchSplinter Review
I'm 99% sure this is a regression from bug 888117, which switched us away from a per-JSON.stringify hashset to a global hashset.  :-(  Bah.  Too bad no one was paying attention to semantics when we over-commoned up there.  Easy fix.  Sort of.

...have I assuaged the worry or made it worse?  :-D
Attachment #8650970 - Flags: review?(jcoppeard)
Assignee: nobody → jwalden+bmo
Status: NEW → ASSIGNED
Blocks: 888117
Comment on attachment 8650970 [details] [diff] [review]
Patch

Review of attachment 8650970 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me.
Attachment #8650970 - Flags: review?(jcoppeard) → review+
https://hg.mozilla.org/mozilla-central/rev/536350cf0da8
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: