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-11599] Property Wrapper composition crash #54004

Closed
theblixguy opened this issue Oct 10, 2019 · 3 comments
Closed

[SR-11599] Property Wrapper composition crash #54004

theblixguy opened this issue Oct 10, 2019 · 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 property wrappers Feature: property wrappers SILGen Area → compiler: The SIL generation stage

Comments

@theblixguy
Copy link
Collaborator

Previous ID SR-11599
Radar rdar://problem/56190608
Original Reporter @theblixguy
Type Bug
Status Closed
Resolution Done
Environment

Swift version 5.1.1-dev (LLVM 1f54080bb6, Swift 97339a6)
Target: x86_64-apple-darwin19.0.0

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

md5: 0cfeca8e7d84ac45ddbf79bf260aff4d

relates to:

  • SR-11600 Property Wrapper composition crash with optional type

Issue Description:

@propertyWrapper 
struct A {
  var wrappedValue: Int
}

@propertyWrapper 
struct B {
  var wrappedValue: Int
}

struct C {
  @A @B var foo: Int
}
Stack dump:
0.  Program arguments: ./swiftc -frontend -typecheck -emit-sil /Users/suyashsrijan/Desktop/test.swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
1.  Swift version 5.1.1-dev (LLVM 1f54080bb6, Swift 97339a6ace)
2.  While silgen emitPropertyWrapperBackingInitializer SIL function "@$s4test1CV3fooSivpfP".
 for 'foo' (at /Users/suyashsrijan/Desktop/test.swift:10:13)
0  swiftc                   0x0000000105be8b95 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swiftc                   0x0000000105be7e45 llvm::sys::RunSignalHandlers() + 85
2  swiftc                   0x0000000105be9178 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff69a23b1d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000000001 _sigtramp + 2522727681
5  swiftc                   0x0000000102d57bf5 swift::TypeBase::dump() const + 21
6  swiftc                   0x000000010236e7cc swift::Lowering::SILGenFunction::emitGeneratorFunction(swift::SILDeclRef, swift::Expr*, bool) + 540
7  swiftc                   0x00000001022f2e4d swift::Lowering::SILGenModule::emitPropertyWrapperBackingInitializer(swift::VarDecl*)::$_7::operator()(swift::SILFunction*) const + 285
8  swiftc                   0x00000001022ed536 swift::Lowering::SILGenModule::emitPropertyWrapperBackingInitializer(swift::VarDecl*) + 278
9  swiftc                   0x00000001023c3342 (anonymous namespace)::SILGenType::visitVarDecl(swift::VarDecl*) + 82
10 swiftc                   0x00000001023c0ecb (anonymous namespace)::SILGenType::emitType() + 379
11 swiftc                   0x00000001023c0d49 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
12 swiftc                   0x00000001022ef2a3 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 867
13 swiftc                   0x00000001022f0229 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 393
14 swiftc                   0x00000001022f05f1 swift::performSILGeneration(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&) + 17
15 swiftc                   0x0000000101fffd60 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 7744
16 swiftc                   0x0000000101ffcfb6 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3046
17 swiftc                   0x0000000101fa6c29 main + 729
18 libdyld.dylib            0x00007fff69822405 start + 1
zsh: segmentation fault  ./swiftc -frontend -typecheck -emit-sil ~/Desktop/test.swift
@belkadan
Copy link
Contributor

Here too. Why isn't the diagnostic kicking in?

@swift-ci create

@theblixguy
Copy link
Collaborator Author

It kicks in when you assign a value, but when you don't it crashes:

/Users/suyashsrijan/Desktop/test.swift:10:7: error: cannot convert value of type 'B' to expected argument type 'Int'
  @A @B var foo: Int = 1
      ^

I think this is because when you assign a value, we are creating/synthesizing an initializer call i.e. A(wrappedValue: B(wrappedValue: 1)) which fails type checking and we get the above error.

@theblixguy
Copy link
Collaborator Author

This no longer crashes on master.

@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 SILGen Area → compiler: The SIL generation stage
Projects
None yet
Development

No branches or pull requests

3 participants