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-15751] compiler crash: SIL verification failed: return value type does not match return type of function #58028

Open
weissi opened this issue Jan 19, 2022 · 2 comments

Comments

@weissi
Copy link
Member

@weissi weissi commented Jan 19, 2022

Previous ID SR-15751
Radar rdar://problem/87776479
Original Reporter @weissi
Type Bug
Environment

Swift version 5.6-dev (LLVM 7b20e61dd04138a, Swift 9438cf6)

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

md5: 67552c562ea62d10b6dd3985eb3eaf5c

Issue Description:

This program

protocol P0 {
    associatedtype Foo

    func foo() -> Foo
}

protocol P1: P0 where Foo == String {
    func foo() -> String
}

func f(_ p1: P1) -> String {
    return p1.foo()
}

crashes at least 5.6 and today's nightly

SIL verification failed: return value type does not match return type of function
  $String
  $*@error_type @opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1.Foo
Verifying instruction:
     %3 = alloc_stack $@error_type @opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1.Foo // users: %7, %6, %5
->   return %3 : $*@error_type @opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1.Foo // id: %7
In function:
// f(_:)
sil hidden [ossa] @$s1t1fySSAA2P1_pF : $@convention(thin) (@in_guaranteed P1) -> @owned String {
// %0 "p1"                                        // users: %2, %1
bb0(%0 : $*P1):
  debug_value %0 : $*P1, let, name "p1", argno 1, expr op_deref // id: %1
  %2 = open_existential_addr immutable_access %0 : $*P1 to $*@opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1 // users: %5, %5, %4
  %3 = alloc_stack $@error_type @opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1.Foo // users: %7, %6, %5
  %4 = witness_method $@opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1, #P0.foo : <Self where Self : P0> (Self) -> () -> Self.Foo, %2 : $*@opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1 : $@convention(witness_method: P0) <τ_0_0 where τ_0_0 : P0> (@in_guaranteed τ_0_0) -> @out τ_0_0.Foo // type-defs: %2; user: %5
  %5 = apply %4<@opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1>(%3, %2) : $@convention(witness_method: P0) <τ_0_0 where τ_0_0 : P0> (@in_guaranteed τ_0_0) -> @out τ_0_0.Foo // type-defs: %2
  dealloc_stack %3 : $*@error_type @opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1.Foo // id: %6
  return %3 : $*@error_type @opened("D5419CE8-7942-11EC-A6FE-0242AC110002") P1.Foo // id: %7
} // end sil function '$s1t1fySSAA2P1_pF'

Stack dump:
0.  Program arguments: /usr/bin/swift-frontend -frontend -interpret t.swift -disable-objc-interop -color-diagnostics -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name t
1.  Swift version 5.6-dev (LLVM 7b20e61dd04138a, Swift 9438cf6b2e83c5f)
2.  Compiling with the current language version
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module t)
4.  While silgen emitFunction SIL function "@$s1t1fySSAA2P1_pF".
 for 'f(_:)' (at t.swift:11:1)
5.  While verifying SIL function "@$s1t1fySSAA2P1_pF".
 for 'f(_:)' (at t.swift:11:1)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/usr/bin/swift-frontend[0x60543e3]
/usr/bin/swift-frontend[0x6051f8e]
/usr/bin/swift-frontend[0x6054776]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f726816b980]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f72663f7fb7]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f72663f9921]
/usr/bin/swift-frontend[0x657987]
/usr/bin/swift-frontend[0x674e04]
/usr/bin/swift-frontend[0x65c70b]
/usr/bin/swift-frontend[0x65a81c]
/usr/bin/swift-frontend[0x65296c]
/usr/bin/swift-frontend[0xb99dfe]
/usr/bin/swift-frontend[0xb98dc9]
/usr/bin/swift-frontend[0xb9b040]
/usr/bin/swift-frontend[0xb97194]
/usr/bin/swift-frontend[0xb9dc71]
/usr/bin/swift-frontend[0xc4f442]
/usr/bin/swift-frontend[0xba1b86]
/usr/bin/swift-frontend[0xb9ee24]
/usr/bin/swift-frontend[0x52732e]
/usr/bin/swift-frontend[0x529cda]
/usr/bin/swift-frontend[0x4b3a97]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f72663dabf7]
/usr/bin/swift-frontend[0x4b34ea]
@weissi
Copy link
Member Author

@weissi weissi commented Jan 19, 2022

@swift-ci create

@hborla
Copy link
Member

@hborla hborla commented Jan 21, 2022

Here's the fix: #40958

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants