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-536] SIL verification failure when local function has captures and default arguments #43153

Closed
swift-ci opened this issue Jan 13, 2016 · 2 comments
Assignees
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

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-536
Radar rdar://24242783
Original Reporter jpedrosa (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

$ uname -a
Linux manga 4.2.0-23-generic #28-Ubuntu SMP Sun Dec 27 17:47:31 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily
$ /home/dewd/apps/swift/swift-2.2-SNAPSHOT-2016-01-11-a-ubuntu15.10/usr/bin/swift -version
Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 42591f7)
Target: x86_64-unknown-linux-gnu

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

md5: 94e225e25b5ec821301f2bb0cd681fad

Issue Description:

Hi,

I'm getting that error message for the past 3 Linux snapshot releases. The code works OK with older releases which I am using. Today after testing it on the latest release and still getting the error message, I dug it up and found that this little snippet reproduces it for me:

class A {

func strftime(mask: String) -> String {
var sb = ""
func process(z: String, padding: Int = 0) {
sb += z
}
return ""
}

}

The error message I get:

$ /home/dewd/apps/swift/swift-2.2-SNAPSHOT-2016-01-11-a-ubuntu15.10/usr/bin/swift build
Compiling Swift Module 'swift_bug' (1 sources)
SIL verification failed: entry point has wrong number of arguments: entry->bbarg_size() == ti->getParameters().size()
In function:
// swift_bug.A.(strftime (Swift.String) -> Swift.String).((process #1) (Swift.String, padding : Swift.Int) -> ()).(default argument 1)
sil shared @TIFFC9swift_bug1A8strftimeFSSSSL_7processFTSS7paddingSi_T_A0 : $@convention(thin) (@owned @box String) -> Int {
bb0:
// function_ref Swift.Int.init (_builtinIntegerLiteral : Builtin.Int2048) -> Swift.Int
%0 = function_ref @TFSiCfT22_builtinIntegerLiteralBi2048_Si : $@convention(thin) (Builtin.Int2048, @thin Int.Type) -> Int // user: %3
%1 = metatype $@thin Int.Type // user: %3
%2 = integer_literal $Builtin.Int2048, 0 // user: %3
%3 = apply %0(%2, %1) : $@convention(thin) (Builtin.Int2048, @thin Int.Type) -> Int // user: %4
return %3 : $Int // id: %4
}

0 swift 0x0000000002f4abf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x0000000002f493f6 llvm::sys::RunSignalHandlers() + 54
2 swift 0x0000000002f4b726
3 libpthread.so.0 0x00007fcd27421d10
4 libc.so.6 0x00007fcd267db267 gsignal + 55
5 libc.so.6 0x00007fcd267dceca abort + 362
6 swift 0x00000000009154a0
7 swift 0x000000000091139f swift::SILFunction::verify() const + 1743
8 swift 0x0000000000947613
9 swift 0x0000000000943ffd
10 swift 0x0000000000943a98
11 swift 0x00000000009d2a97
12 swift 0x00000000009d28be
13 swift 0x00000000009aa69a
14 swift 0x000000000094cbda
15 swift 0x0000000000943c97
16 swift 0x00000000009d8307
17 swift 0x00000000009d7d8d
18 swift 0x0000000000949f4b
19 swift 0x000000000094ac52 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 482
20 swift 0x000000000094b1e6 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 118
21 swift 0x0000000000765ffa
22 swift 0x0000000000761dfe frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2590
23 swift 0x000000000075d513 main + 2835
24 libc.so.6 0x00007fcd267c6a40 __libc_start_main + 240
25 swift 0x000000000075c8f9 _start + 41
Stack dump:
0. Program arguments: /home/dewd/apps/swift/swift-2.2-SNAPSHOT-2016-01-11-a-ubuntu15.10/usr/bin/swift -frontend -c -primary-file /home/dewd/t_/swift_bug/Sources/main.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/dewd/t_/swift_bug/.build/debug -I /usr/local/include -g -D SWIFT_PACKAGE -emit-module-doc-path /home/dewd/t_/swift_bug/.build/debug/swift_bug.o/swift_bug/main~partial.swiftdoc -Onone -module-name swift_bug -emit-module-path /home/dewd/t_/swift_bug/.build/debug/swift_bug.o/swift_bug/main~partial.swiftmodule -emit-dependencies-path /home/dewd/t_/swift_bug/.build/debug/swift_bug.o/swift_bug/main.d -emit-reference-dependencies-path /home/dewd/t_/swift_bug/.build/debug/swift_bug.o/swift_bug/main.swiftdeps -o /home/dewd/t_/swift_bug/.build/debug/swift_bug.o/Sources/main.swift.o

  1. While emitting SIL for 'strftime' at /home/dewd/t_/swift_bug/Sources/main.swift:5:3
  2. While silgen emitDefaultArgGenerator SIL function @TIFFC9swift_bug1A8strftimeFSSSSL_7processFTSS7paddingSi_T_A0 for expression at [/home/dewd/t_/swift_bug/Sources/main.swift:7:44 - line:7:44] RangeText="0"
  3. While verifying SIL function @TIFFC9swift_bug1A8strftimeFSSSSL_7processFTSS7paddingSi_T_A0 for expression at [/home/dewd/t_/swift_bug/Sources/main.swift:7:44 - line:7:44] RangeText="0"
    <unknown>:0: error: unable to execute command: Aborted
    <unknown>:0: error: compile command failed due to signal (use -v to see invocation)
    <unknown>:0: error: build had 1 command failures
    error: exit(1): ["/home/dewd/apps/swift/swift-2.2-SNAPSHOT-2016-01-11-a-ubuntu15.10/usr/bin/swift-build-tool", "-f", "/home/dewd/t_/swift_bug/.build/debug/swift_bug.o/llbuild.yaml"]
@belkadan
Copy link
Contributor

Reduced further:

func test(mask: String) -> String {
  var sb = ""
  func process(z: String, padding: Int = 0) { sb += z }
  return ""
}

@slavapestov
Copy link
Contributor

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

No branches or pull requests

4 participants