Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14504] [Windows] NSKeyedUnarchiver doesn’t support reference cycles #4214

Open
swift-ci opened this issue Apr 17, 2021 · 1 comment
Open

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-14504
Radar None
Original Reporter Eugene Gubin (JIRA User)
Type Bug
Environment

swift-DEVELOPMENT-SNAPSHOT-03-25-a-windows10

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, Windows
Assignee None
Priority Medium

md5: 2d0adc051f541edd78bb07f5c76c73c6

Issue Description:

Code below crashes with C00000FD (STATUS_STACK_OVERFLOW)

import Foundation

class C: NSObject, NSCoding {
 func encode(with aCoder: NSCoder) {
 aCoder.encode(d, forKey: "d")
 }

 required init?(coder aDecoder: NSCoder) {
 d = aDecoder.decodeObject(forKey: "d") as? D
 }

 override init() { super.init() }

 var d: D?
}

class D: NSObject, NSCoding {
 func encode(with aCoder: NSCoder) {
 aCoder.encode(c, forKey: "c")
 }

 required init?(coder aDecoder: NSCoder) {
 c = aDecoder.decodeObject(forKey: "c") as? C
 }

 override init() { super.init() }

 var c: C?
}

let c = C()
let d = D()
c.d = d
d.c = c

let data2 = NSKeyedArchiver.archivedData(withRootObject: c)
// crashes here
let c_out_any: Any? = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data2)
let c_out = c_out_any as? C
print("c: \(c_out)")
@typesanitizer
Copy link

cc @compnerd

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants