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-13552] Property wrapper with initializer accepting closure and any additional argument causes segmentation fault #55989

Closed
swift-ci opened this issue Sep 15, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software property wrappers Feature: property wrappers type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13552
Radar rdar://problem/68926346
Original Reporter acedened (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Additional Detail from JIRA
Votes 3
Component/s Compiler
Labels Bug, CompilerCrash, PropertyWrappers, TypeChecker
Assignee None
Priority Medium

md5: ffeb80bfb1012bdae8d212d1213cc42d

duplicates:

  • SR-13069 Crash when using autoclosure escaping in property wrappers

Issue Description:

This code causes "Segmentation fault: 11" error on the latest Xcode 12 beta

@propertyWrapper
struct MyWrapper<T> {
    let defaultValue: () -> T
    let key: String
    
    init(wrappedValue: @escaping @autoclosure () -> T, key: String) {
        self.defaultValue = wrappedValue
        self.key = key
    }

    var wrappedValue: T {
        get { self.defaultValue() }
        set {}
    }
}

struct MyStruct {
    @MyWrapper(key: "int")
    var int = 0
}

The error disappears in following cases:

  1. Not using closures and just passing wrappedValue as is

  2. Removing second init argument

  3. Writing

struct MyStruct {
    @MyWrapper(wrappedValue: 0, key: "int")
    var int: Int
}

instead of

struct MyStruct {
    @MyWrapper(key: "int")
    var int = 0
}

Stack trace is attached below

@typesanitizer
Copy link

@swift-ci create

@jckarter
Copy link
Member

This looks like SR-13069, which was fixed in #32866 You could try a master snapshot toolchain from swift.org to see whether this is fixed for you.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software property wrappers Feature: property wrappers type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants