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-11545] SIL crash with tuple and throwing initializer #53946

Closed
tayloraswift opened this issue Sep 29, 2019 · 3 comments
Closed

[SR-11545] SIL crash with tuple and throwing initializer #53946

tayloraswift opened this issue Sep 29, 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 SILGen Area → compiler: The SIL generation stage

Comments

@tayloraswift
Copy link
Contributor

Previous ID SR-11545
Radar rdar://problem/55842518
Original Reporter @Kelvin13
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift version 5.1-dev (LLVM c5340df2d1, Swift 27e881d)
Target: x86_64-unknown-linux-gnu

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

md5: ac4d75a66ce6a87683a7ee537ae984c3

Issue Description:

compiling the attached swift file produces the following crash:

SIL memory lifetime failure in @$s4main1SVACycfC: lifetime mismatch in predecessors
memory location:   %8 = tuple_element_addr %7 : $*(C, C), 0        // user: %9
at instruction:   %26 = begin_borrow %25 : $Error                 // user: %27in function:
// S.init()
sil hidden [ossa] @$s4main1SVACycfC : $@convention(method) (@thin S.Type) -> @owned S {
bb0(%0 : $@thin S.Type):
  %1 = alloc_stack $S, var, name "self"           // users: %21, %15, %6, %22, %23
  %2 = metatype $@thick C.Type                    // user: %4
  // function_ref C.__allocating_init()
  %3 = function_ref @$s4main1CCACyKcfC : $@convention(method) (@thick C.Type) -> (@owned C, @error Error) // user: %4
  try_apply %3(%2) : $@convention(method) (@thick C.Type) -> (@owned C, @error Error), normal bb1, error bb5 // id: %4// %5                                             // user: %9
bb1(%5 : @owned $C):                              // Preds: bb0
  %6 = begin_access [modify] [static] %1 : $*S    // users: %10, %7
  %7 = struct_element_addr %6 : $*S, #S.cc        // user: %8
  %8 = tuple_element_addr %7 : $*(C, C), 0        // user: %9
  store %5 to [init] %8 : $*C                     // id: %9
  end_access %6 : $*S                             // id: %10
  %11 = metatype $@thick C.Type                   // user: %13
  // function_ref C.__allocating_init()
  %12 = function_ref @$s4main1CCACyKcfC : $@convention(method) (@thick C.Type) -> (@owned C, @error Error) // user: %13
  try_apply %12(%11) : $@convention(method) (@thick C.Type) -> (@owned C, @error Error), normal bb2, error bb6 // id: %13// %14                                            // user: %18
bb2(%14 : @owned $C):                             // Preds: bb1
  %15 = begin_access [modify] [static] %1 : $*S   // users: %19, %16
  %16 = struct_element_addr %15 : $*S, #S.cc      // user: %17
  %17 = tuple_element_addr %16 : $*(C, C), 1      // user: %18
  store %14 to [init] %17 : $*C                   // id: %18
  end_access %15 : $*S                            // id: %19
  br bb3                                          // id: %20bb3:                                              // Preds: bb2
  %21 = load [copy] %1 : $*S                      // user: %24
  destroy_addr %1 : $*S                           // id: %22
  dealloc_stack %1 : $*S                          // id: %23
  return %21 : $S                                 // id: %24// %25                                            // user: %26
bb4(%25 : @owned $Error):                         // Preds: bb6 bb5
  %26 = begin_borrow %25 : $Error                 // user: %27
  %27 = copy_value %26 : $Error                   // user: %28
  debug_value %27 : $Error, let, name "error"     // id: %28
  %29 = string_literal utf8 "try-tuple.swift"     // user: %34
  %30 = integer_literal $Builtin.Word, 15         // user: %34
  %31 = integer_literal $Builtin.Int1, -1         // user: %34
  %32 = metatype $@thin StaticString.Type         // user: %34
  // function_ref StaticString.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
  %33 = function_ref @$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin StaticString.Type) -> StaticString // user: %34
  %34 = apply %33(%29, %30, %31, %32) : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin StaticString.Type) -> StaticString // user: %44
  %35 = integer_literal $Builtin.IntLiteral, 21   // user: %38
  %36 = metatype $@thin UInt.Type                 // user: %38
  // function_ref UInt.init(_builtinIntegerLiteral:)
  %37 = function_ref @$sSu22_builtinIntegerLiteralSuBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin UInt.Type) -> UInt // user: %38
  %38 = apply %37(%35, %36) : $@convention(method) (Builtin.IntLiteral, @thin UInt.Type) -> UInt // user: %44
  // function_ref default argument 0 of fatalError(_:file:line:)
  %39 = function_ref @$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_ : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String // user: %40
  %40 = apply %39() : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String // user: %41
  %41 = copy_value %40 : $@callee_guaranteed () -> @owned String // users: %45, %42
  %42 = convert_escape_to_noescape %41 : $@callee_guaranteed () -> @owned String to $@noescape @callee_guaranteed () -> @owned String // user: %44
  // function_ref fatalError(_:file:line:)
  %43 = function_ref @$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutF : $@convention(thin) (@noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> Never // user: %44
  %44 = apply %43(%42, %34, %38) : $@convention(thin) (@noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> Never
  destroy_value %41 : $@callee_guaranteed () -> @owned String // id: %45
  unreachable                                     // id: %46// %47                                            // user: %48
bb5(%47 : @owned $Error):                         // Preds: bb0
  br bb4(%47 : $Error)                            // id: %48// %49                                            // user: %50
bb6(%49 : @owned $Error):                         // Preds: bb1
  br bb4(%49 : $Error)                            // id: %50
} // end sil function '$s4main1SVACycfC'Stack dump:
0.  Program arguments: /home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift -frontend -interpret try-tuple.swift -disable-objc-interop -color-diagnostics -module-name main 
1.  Swift version 5.1-dev (LLVM c5340df2d1, Swift 27e881d97e)
2.  While running pass #​51 SILModuleTransform "OwnershipModelEliminator".
3.  While verifying SIL function "@$s4main1SVACycfC".
 for 'init()' (at try-tuple.swift:12:5)
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x46aa694]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x46a82ee]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x46aa948]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7fdffb9db890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fdff9e3ee97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7fdff9e40801]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0xd9ed40]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0xda0020]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0xda11e7]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0xda12f3]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0xe35aa0]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0xa0b149]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x95338f]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x953d51]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x552e08]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x95be0d]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x74b5d8]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x4ddfd2]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x4d4f59]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x4d207d]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x474360]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fdff9e21b97]
/home/klossy/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2019-09-20-a/usr/bin/swift[0x473faa]
Aborted (core dumped)
@belkadan
Copy link
Contributor

Same on master. @gottesmm, any ideas?

@swift-ci create

@gottesmm
Copy link
Member

This isn't actually related to the ownership model eliminator. What is happening here is that I added an extra verification run before lowering ownership in the ownership model eliminator to catch ownership violations that we were missing since we were not normally verifying until the end of the pipeline (after ownership has been lowered).

This is more likely to be an optimizer pass misbehaving since if it was SILGen, the verification run right after SILGen runs would catch it. I would suggest running with -sil-verify-all to find the culprit pass.

@eeckstein
Copy link
Member

Fixed in #27457

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

No branches or pull requests

5 participants