-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Open
Labels
access controlFeature → modifiers: Access control and access levelsFeature → modifiers: Access control and access levelsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfregressionswift 4.2
Description
| Previous ID | SR-8990 |
| Radar | rdar://problem/45274900 |
| Original Reporter | @jckarter |
| Type | Bug |
Attachment: Download
Additional Detail from JIRA
| Votes | 1 |
| Component/s | Compiler |
| Labels | Bug, 4.2Regression |
| Assignee | @jckarter |
| Priority | Medium |
md5: cc1eadc6334f9f313216b81e73193004
Issue Description:
Users report their app is crashing due to a use-after-free when modifying a nonmutating property defined on a protocol extension. Test case project here:
They note that a snapshot compiler with asserts on hits an assertion failure:
The problem occurs when a property defined in a protocol or protocol extension with a nonmutating setter is mutated indirectly, as in:
import CoreGraphics
protocol SomeProtocol { }
class SomeClass: SomeProtocol { }
extension SomeProtocol {
var someGetter: CGPoint {
nonmutating set { _ = self }
get { return .zero }
}
}
SomeClass().someGetter.x = 42 // releases SomeClass() too earlyThe problem can be worked around by separating the `get` and `set` of the nonmutating property into their own statements:
let someObject = SomeClass()
var temp = someObject.someGetter // first get the property
temp.x = 42 // update the value
someObject.someGetter = temp // then set the propertyReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
access controlFeature → modifiers: Access control and access levelsFeature → modifiers: Access control and access levelsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfregressionswift 4.2