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-12049] Compiler crash emitting IR SIL when property wrapper has stored property but no explicit initializer #54485

Closed
lilyball mannequin opened this issue Jan 18, 2020 · 3 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 IRGen LLVM IR generation property wrappers Feature: property wrappers swift 5.1

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Jan 18, 2020

Previous ID SR-12049
Radar rdar://problem/58861175
Original Reporter @lilyball
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin19.2.0

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

md5: 5efc2dcd8ef21979089b997a2879bbbd

Issue Description:

When a property wrapper contains a stored property (other than wrappedValue) but does not contain an explicitly-written initializer, the compiler will crash emitting the initializer for a type that uses this property wrapper. Writing an explicit initializer fixes the crash.

Reproduction:

@propertyWrapper
struct Foo {
    var wrappedValue: Bool

    var prop = "something"
}

class Bar {
    @Foo
    var enabled = true
}
Stack dump:
0.      Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file unnamed.swift -target x86_64-apple-macosx10.15 -enable-objc-interop -sdk /Applications/X
code.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -module-name unnamed -o /var/folders/nq/dmc1zzf93
8163pj2rm8tcrbr0000gn/T/unnamed-a5f210.o
1.      While emitting IR SIL function "@$s7unnamed3BarCACycfc".
 for 'init()' (at unnamed.swift:8:7)
0  swift                    0x000000010a478a63 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010a478236 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff721a242d _sigtramp + 29
3  swift                    0x000000010a344c9f llvm::FoldingSet<llvm::AttributeSetNode>::NodeEquals(llvm::FoldingSetBase::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) const + 95
4  libsystem_c.dylib        0x00007fff72077a1c abort + 120
5  libsystem_malloc.dylib   0x00007fff7216d647 has_default_zone0 + 0
6  libsystem_malloc.dylib   0x00007fff7217040e malloc_report + 151
7  libsystem_malloc.dylib   0x00007fff72161275 realloc + 312
8  swift                    0x0000000106190a4d swift::irgen::SingleScalarTypeInfo<(anonymous namespace)::ClassTypeInfo, swift::irgen::ReferenceTypeInfo>::getSchema(swift::irgen::ExplosionSchema&) const + 157
9  swift                    0x000000010630617e swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 35646
10 swift                    0x00000001062faaca swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9834
11 swift                    0x00000001061a5bd0 swift::irgen::IRGenerator::emitGlobalTopLevel() + 1712
12 swift                    0x00000001062d7845 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPa
ths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1189
13 swift                    0x00000001060c2981 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 36673
14 swift                    0x00000001060b6234 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
15 swift                    0x0000000106043733 main + 1219
16 libdyld.dylib            0x00007fff71fa97fd start + 1
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

Workaround:

@propertyWrapper
struct Foo {
    var wrappedValue: Bool

    init(wrappedValue: Bool) {
        self.wrappedValue = wrappedValue
    }

    var prop = "something"
}

class Bar {
    @Foo
    var enabled = true
}
@theblixguy
Copy link
Collaborator

This doesn't crash on 5.2.

@beccadax
Copy link
Contributor

@swift-ci create

@eeckstein
Copy link
Member

This seems to be fixed.
Please re-open this issue if you still see the problem in swift-5.2

@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
@AnthonyLatsis AnthonyLatsis added IRGen LLVM IR generation swift 5.1 labels May 14, 2023
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 IRGen LLVM IR generation property wrappers Feature: property wrappers swift 5.1
Projects
None yet
Development

No branches or pull requests

4 participants