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

RESOLVED FIXED in Firefox 43

Status

()

Core
JavaScript: Standard Library
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: anba, Assigned: Waldo)

Tracking

Trunk
mozilla43
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox43 fixed)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
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`
(Assignee)

Comment 1

3 years ago
Created attachment 8650970 [details] [diff] [review]
Patch

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)

Updated

3 years ago
Assignee: nobody → jwalden+bmo
Status: NEW → ASSIGNED
(Assignee)

Updated

3 years ago
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
Last Resolved: 3 years ago
status-firefox43: affected → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in before you can comment on or make changes to this bug.