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-11059] Abort 6: Property wrapper with default value in initialiser #53451

Closed
Agarunov opened this issue Jul 2, 2019 · 5 comments
Closed
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

Comments

@Agarunov
Copy link

Agarunov commented Jul 2, 2019

Previous ID SR-11059
Radar rdar://problem/55480280
Original Reporter @Agarunov
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 11.0 beta 3 (11M362v)

Toolchain: Swift 5.1 Snapshot 2019-07-01 (a)

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

md5: c4ae548aaf5526dfc2b976e49a439843

is duplicated by:

  • SR-11096 Abort 6: Property wrapper with closure argument with default value
  • SR-11487 Property Wrapper example from "The Swift Programming Language" book crashes
  • SR-11692 Compiler crash in property wrappers
  • SR-11492 Property Wrapper, a compiler crash with default param

Issue Description:

This code crashes:

class Value {
    @A var some: Int = 100
}

@propertyWrapper
struct A {
    var wrappedValue: Int
    
    init(wrappedValue initialValue: Int, string: String = "") {
        self.wrappedValue = initialValue
    }
}
SIL verification failed: return value type does not match return type of function: functionResultType == instResultType
Verifying instruction:
     %8 = apply %7(%4, %6, %0) : $@convention(method) (Int, @owned String, @thin A.Type) -> A // user: %9
->   return %8 : $A                               // id: %9
In function:
// variable initialization expression of AppDelegate._some
sil [transparent] [ossa] @$s8FilterPW11AppDelegateC5_some33_25BD6E4F800CC40E9ACE8F1CEA4F4D7CLLAA1AVvpfi : $@convention(thin) () -> Int {
bb0:
  %0 = metatype $@thin A.Type                     // user: %8
  %1 = integer_literal $Builtin.IntLiteral, 100   // user: %4
  %2 = metatype $@thin Int.Type                   // user: %4
  // function_ref Int.init(_builtinIntegerLiteral:)
  %3 = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // user: %4
  %4 = apply %3(%1, %2) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // user: %8
  // function_ref default argument 1 of A.init(initialValue:string:)
  %5 = function_ref @$s8FilterPW1AV12initialValue6stringACSi_SStcfcfA0_ : $@convention(thin) () -> @owned String // user: %6
  %6 = apply %5() : $@convention(thin) () -> @owned String // user: %8
  // function_ref A.init(initialValue:string:)
  %7 = function_ref @$s8FilterPW1AV12initialValue6stringACSi_SStcfC : $@convention(method) (Int, @owned String, @thin A.Type) -> A // user: %8
  %8 = apply %7(%4, %6, %0) : $@convention(method) (Int, @owned String, @thin A.Type) -> A // user: %9
  return %8 : $A                                  // id: %9
} // end sil function '$s8FilterPW11AppDelegateC5_some33_25BD6E4F800CC40E9ACE8F1CEA4F4D7CLLAA1AVvpfi'
0  swift                    0x000000010edd61d5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010edd54c5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010edd67b8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff6d852b5d _sigtramp + 29
4  swift                    0x0000000110c1b000 (anonymous namespace)::DarwinX86AsmBackend::getCompactUnwindRegNum(unsigned int) const::CU64BitRegs + 219474
5  libsystem_c.dylib        0x00007fff6d70c6a6 abort + 127
6  swift                    0x000000010bdb14d8 (anonymous namespace)::SILVerifier::_require(bool, llvm::Twine const&, std::__1::function<void ()> const&) + 616
7  swift                    0x000000010bdc4b7c swift::SILInstructionVisitor<(anonymous namespace)::SILVerifier, void>::visit(swift::SILInstruction*) + 67836
8  swift                    0x000000010bdb300c (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 1484
9  swift                    0x000000010bdadca7 swift::SILFunction::verify(bool) const + 7303
10 swift                    0x000000010b8617ad swift::Lowering::SILGenModule::postEmitFunction(swift::SILDeclRef, swift::SILFunction*) + 205
11 swift                    0x000000010b86a1d6 swift::Lowering::SILGenModule::emitStoredPropertyInitialization(swift::PatternBindingDecl*, unsigned int)::$_6::operator()(swift::SILFunction*) const + 422
12 swift                    0x000000010b863fe8 swift::Lowering::SILGenModule::emitStoredPropertyInitialization(swift::PatternBindingDecl*, unsigned int) + 536
13 swift                    0x000000010b93390d (anonymous namespace)::SILGenType::emitType() + 381
14 swift                    0x000000010b933789 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
15 swift                    0x000000010b866386 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 822
16 swift                    0x000000010b8671e5 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 293
17 swift                    0x000000010b867706 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&) + 38
18 swift                    0x000000010b58d1bf performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 8255
19 swift                    0x000000010b58a25a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3002
20 swift                    0x000000010b5330c8 main + 696
21 libdyld.dylib            0x00007fff6d6673d5 start + 1
error: Abort trap: 6 
@belkadan
Copy link
Contributor

belkadan commented Jul 6, 2019

@gottesmm, I think this is the one you just fixed!

@Agarunov
Copy link
Author

Agarunov commented Aug 9, 2019

Fixed on master, but not in latest swift 5.1 toolchain (25.07.2019)

@belkadan
Copy link
Contributor

Cloning to make sure it gets cherry-picked.

@swift-ci create

@belkadan
Copy link
Contributor

(Updated test case for final property wrapper syntax.)

@DougGregor
Copy link
Member

It's fixed on master, but the fixes are too invasive to bring over to 5.1

@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
Projects
None yet
Development

No branches or pull requests

4 participants