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-11764] @propertyWrapper compiler crash #54171

Closed
swift-ci opened this issue Nov 11, 2019 · 2 comments
Closed

[SR-11764] @propertyWrapper compiler crash #54171

swift-ci opened this issue Nov 11, 2019 · 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-11764
Radar None
Original Reporter asoulier91 (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

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

md5: b53c9b6502c8cd932191eb4c24dbfd39

duplicates:

  • SR-11717 Property Wrapper Compiler Segfault

Issue Description:

Getting a segmentation fault 11 during compilation while using a @propertyWrapper if they are not in the same file.

It compiles and works fine when they are on the same file or if the propertyWrapper is in a separated module.

@propertyWrapper
public struct Binded<Value, EnclosingSelf> {
    private let keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>

    public init(to keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>) {
        self.keyPath = keyPath
    }

    public var wrappedValue: Value {
        get { fatalError("called wrappedValue getter") }
        set { fatalError("called wrappedValue getter") }
    }

    public static subscript(
        _enclosingInstance instance: EnclosingSelf,
        wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
        storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Self>
    ) -> Value {
        get {
            let wrapper = instance[keyPath: storageKeyPath]
            return instance[keyPath: wrapper.keyPath]
        }
        set {
            let wrapper = instance[keyPath: storageKeyPath]
            instance[keyPath: wrapper.keyPath] = newValue
        }
    }
}
@Binded(to: \InputView.textField.placeholder)
public var placeholder: String?
Stack dump:
0. Program arguments: /Applications/Xcode 11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/asoulier/Desktop/TestBinding/TestBinding/ViewController.swift -primary-file /Users/asoulier/Desktop/TestBinding/TestBinding/InputView.swift /Users/asoulier/Desktop/TestBinding/TestBinding/AppDelegate.swift /Users/asoulier/Desktop/TestBinding/TestBinding/Binded.swift /Users/asoulier/Desktop/TestBinding/TestBinding/SceneDelegate.swift -emit-module-path /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/Objects-normal/x86_64/InputView~partial.swiftmodule -emit-module-doc-path /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/Objects-normal/x86_64/InputView~partial.swiftdoc -serialize-diagnostics-path /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/Objects-normal/x86_64/InputView.dia -emit-dependencies-path /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/Objects-normal/x86_64/InputView.d -emit-reference-dependencies-path /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/Objects-normal/x86_64/InputView.swiftdeps -target x86_64-apple-ios13.0-simulator -enable-objc-interop -sdk /Applications/Xcode 11.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.0.sdk -I /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Products/Debug-iphonesimulator -F /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/asoulier/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -working-directory -Xcc /Users/asoulier/Desktop/TestBinding -enable-anonymous-context-mangled-names -Xcc -I/Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/TestBinding-generated-files.hmap -Xcc -I/Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/TestBinding-own-target-headers.hmap -Xcc -I/Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/TestBinding-all-target-headers.hmap -Xcc -iquote -Xcc /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/TestBinding-project-headers.hmap -Xcc -I/Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/DerivedSources-normal/x86_64 -Xcc -I/Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/DerivedSources/x86_64 -Xcc -I/Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/DerivedSources -Xcc -DDEBUG=1 -module-name TestBinding -o /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Build/Intermediates.noindex/TestBinding.build/Debug-iphonesimulator/TestBinding.build/Objects-normal/x86_64/InputView.o -index-store-path /Users/asoulier/Library/Developer/Xcode/DerivedData/TestBinding-dsrltrvjmopfkegepoizlktojfcm/Index/DataStore -index-system-modules 
1. While type-checking getter for placeholder (at /Users/asoulier/Desktop/TestBinding/TestBinding/InputView.swift:18:16)
2. While type-checking statement at [/Users/asoulier/Desktop/TestBinding/TestBinding/InputView.swift:18:16 - line:18:16] RangeText=""
3. While type-checking statement at [<invalid loc> - <invalid loc>]
4. While type-checking expression at [<invalid loc> - <invalid loc>]
0  swift                    0x000000010b8b2eb3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010b8b2686 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff704acb1d _sigtramp + 29
3  libsystem_platform.dylib 0x0000000400000002 _sigtramp + 2411017474
4  swift                    0x0000000107fa7fa5 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) + 341
5  swift                    0x0000000107f026cb (anonymous namespace)::ConstraintGenerator::addSubscriptConstraints(swift::Expr*, swift::Type, swift::Expr*, swift::ValueDecl*, swift::constraints::ConstraintLocator*) + 2011
6  swift                    0x0000000107ef996d (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 141
7  swift                    0x0000000107ef3f03 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*, swift::DeclContext*) + 883
8  swift                    0x0000000107f473c2 swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 8338
9  swift                    0x00000001080405c2 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 1042
10 swift                    0x00000001080f1e66 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 20678
11 swift                    0x00000001080f3001 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 129
12 swift                    0x00000001080f2a93 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 23795
13 swift                    0x00000001080ecd41 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 129
14 swift                    0x00000001080ec840 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 5456
15 swift                    0x00000001080f49a1 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 561
16 swift                    0x00000001081114a2 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2082
17 swift                    0x000000010780d58b swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t)::$_0::operator()(swift::SourceFile&) const + 91
18 swift                    0x000000010780c2eb swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 5371
19 swift                    0x0000000107501b6f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 815
20 swift                    0x00000001074fe034 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
21 swift                    0x000000010748b5a3 main + 1219
22 libdyld.dylib            0x00007fff702ab405 start + 1
23 libdyld.dylib            0x000000000000004b start + 2413120583
error: Segmentation fault: 11 (in target 'TestBinding' from project 'TestBinding')
@theblixguy
Copy link
Collaborator

This is a duplicate of SR-11717. This has been fixed on master and you can verify using the latest development snapshot.

@swift-ci
Copy link
Collaborator Author

Comment by Anthony Soulier (JIRA)

Thanks @theblixguy, I can confirm it compiles fine using the latest development snapshot.

@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

3 participants