Skip to content

[SR-4404] SIL verification failed: more than one throw block in function: !FoundThrowBlock #46983

Open
@lilyball

Description

@lilyball
mannequin
Previous ID SR-4404
Radar rdar://problem/31482535
Original Reporter @lilyball
Type Bug
Environment

Swift version 3.1 (swift-3.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Swift version 3.0.2 (swift-3.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu

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

md5: 931c080663edf1e2614afa69e6c42aa9

Issue Description:

Compiling PMJSON on Linux in the release configuration fails in SIL verification with the error "more than one throw block in function: !FoundThrowBlock". I've reproduced this using both Swift 3.0 and Swift 3.1, with PMJSON v2.0.2, with the following command: docker run --rm -it -v $PWD:/source -w /source swift:3.1 swift build -c release. The function it fails on is very trivial, and if I comment it out, it just fails on a different function. The one it's failing on for me right now looks like

    func getBool() throws -> Bool {
        guard let b = self.bool else { throw JSONError.missingOrInvalidType(path: nil, expected: .required(.bool), actual: .forValue(self)) }
        return b
    }

Here's the complete build output:

Compile Swift Module 'PMJSON' (9 sources)
SIL verification failed: more than one throw block in function: !FoundThrowBlock
In function:
sil_scope 1 { loc "/source/Sources/JSONError.swift":139:10 parent @_TFO6PMJSON4JSON7getBoolfzT_Sb : $@convention(method) (@guaranteed JSON) -> (Bool, @error Error) }
sil_scope 2 { loc "/source/Sources/Accessors.swift":108:9 parent @_TFO6PMJSON4JSONg4boolGSqSb_ : $@convention(method) (@guaranteed JSON) -> Optional<Bool> }
sil_scope 3 { loc "/source/Sources/JSONError.swift":142:5 parent 1 }
sil_scope 4 { loc "/source/Sources/JSONError.swift":140:28 parent 3 }
sil_scope 5 { loc "/source/Sources/Accessors.swift":108:9 parent 2 inlined_at 4 }
sil_scope 6 { loc "/source/Sources/Accessors.swift":113:9 parent 2 }
sil_scope 7 { loc "/source/Sources/Accessors.swift":112:13 parent 6 }
sil_scope 8 { loc "/source/Sources/Accessors.swift":112:13 parent 7 inlined_at 4 }
sil_scope 9 { loc "/source/Sources/Accessors.swift":112:13 parent 7 }
sil_scope 10 { loc "/source/Sources/Accessors.swift":112:13 parent 9 inlined_at 4 }
sil_scope 11 { loc "/source/Sources/JSONError.swift":140:141 parent 3 }
sil_scope 12 { loc "/source/Sources/JSONError.swift":111:30 parent @_TZFOO6PMJSON9JSONError8JSONType8forValuefOS_4JSONS1_ : $@convention(method) (@owned JSON, @thin JSONError.JSONType.Type) -> JSONError.JSONType }
sil_scope 13 { loc "/source/Sources/JSONError.swift":140:138 parent 11 }
sil_scope 14 { loc "/source/Sources/JSONError.swift":111:30 parent 12 inlined_at 13 }
sil_scope 15 { loc "/source/Sources/JSONError.swift":126:9 parent 12 }
sil_scope 16 { loc "/source/Sources/JSONError.swift":125:13 parent 15 }
sil_scope 17 { loc "/source/Sources/JSONError.swift":125:13 parent 16 inlined_at 13 }
sil_scope 18 { loc "/source/Sources/JSONError.swift":113:33 parent 15 }
sil_scope 19 { loc "/source/Sources/JSONError.swift":113:33 parent 18 inlined_at 13 }
sil_scope 20 { loc "/source/Sources/JSONError.swift":115:35 parent 15 }
sil_scope 21 { loc "/source/Sources/JSONError.swift":115:35 parent 20 inlined_at 13 }
sil_scope 22 { loc "/source/Sources/JSONError.swift":125:13 parent 16 }
sil_scope 23 { loc "/source/Sources/JSONError.swift":125:13 parent 22 inlined_at 13 }
sil_scope 24 { loc "/source/Sources/JSONError.swift":116:43 parent 15 }
sil_scope 25 { loc "/source/Sources/JSONError.swift":116:43 parent 24 inlined_at 13 }
sil_scope 26 { loc "/source/Sources/JSONError.swift":125:13 parent 16 }
sil_scope 27 { loc "/source/Sources/JSONError.swift":125:13 parent 26 inlined_at 13 }
sil_scope 28 { loc "/source/Sources/JSONError.swift":122:17 parent 15 }
sil_scope 29 { loc "/source/Sources/JSONError.swift":122:17 parent 28 inlined_at 13 }
sil_scope 30 { loc "/source/Sources/JSONError.swift":123:35 parent 15 }
sil_scope 31 { loc "/source/Sources/JSONError.swift":123:35 parent 30 inlined_at 13 }
sil_scope 32 { loc "/source/Sources/JSONError.swift":124:34 parent 15 }
sil_scope 33 { loc "/source/Sources/JSONError.swift":124:34 parent 32 inlined_at 13 }

// JSON.getBool() throws -> Bool
sil @_TFO6PMJSON4JSON7getBoolfzT_Sb : $@convention(method) (@guaranteed JSON) -> (Bool, @error Error) {
// %0                                             // users: %14, %13, %3, %2, %1
bb0(%0 : $JSON):
  debug_value %0 : $JSON, let, name "self", argno 1, loc "/source/Sources/JSONError.swift":139:10, scope 1 // id: %1
  debug_value %0 : $JSON, let, name "self", argno 1, loc "/source/Sources/Accessors.swift":108:9, scope 5 // id: %2
  switch_enum %0 : $JSON, case #JSON.bool!enumelt.1: bb1, default bb2, loc "/source/Sources/Accessors.swift":110:18, scope 8 // id: %3

// %4                                             // users: %6, %7, %5
bb1(%4 : $Bool):                                  // Preds: bb0
  debug_value %4 : $Bool, let, name "b", loc "/source/Sources/Accessors.swift":110:28, scope 10 // id: %5
  debug_value %4 : $Bool, let, name "b", loc "/source/Sources/JSONError.swift":140:19, scope 3 // id: %6
  return %4 : $Bool, loc "/source/Sources/JSONError.swift":141:9, scope 3 // id: %7

bb2:                                              // Preds: bb0
  %8 = alloc_existential_box $Error, $JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // users: %26, %33, %41, %50, %57, %64, %20, %9
  %9 = project_existential_box $JSONError in %8 : $Error, loc "/source/Sources/JSONError.swift":140:56, scope 11 // users: %25, %32, %40, %49, %56, %63, %19
  %10 = enum $Optional<String>, #Optional.none!enumelt, loc "/source/Sources/JSONError.swift":140:83, scope 11 // users: %23, %30, %38, %47, %54, %61, %17
  %11 = enum $JSONError.JSONType, #JSONError.JSONType.bool!enumelt, loc "/source/Sources/JSONError.swift":140:109, scope 11 // users: %22, %12
  %12 = enum $JSONError.ExpectedType, #JSONError.ExpectedType.required!enumelt.1, %11 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:99, scope 11 // users: %23, %30, %38, %47, %54, %61, %17
  debug_value %0 : $JSON, let, name "value", argno 1, loc "/source/Sources/JSONError.swift":111:41, scope 14 // id: %13
  switch_enum %0 : $JSON, case #JSON.null!enumelt: bb3, case #JSON.bool!enumelt.1: bb4, case #JSON.string!enumelt.1: bb5, case #JSON.int64!enumelt.1: bb6, case #JSON.double!enumelt.1: bb8, case #JSON.decimal!enumelt.1: bb9, case #JSON.object!enumelt.1: bb10, case #JSON.array!enumelt.1: bb11, loc "/source/Sources/JSONError.swift":113:18, scope 17 // id: %14

bb3:                                              // Preds: bb2
  %15 = enum $JSONError.JSONType, #JSONError.JSONType.null!enumelt, loc "/source/Sources/JSONError.swift":113:33, scope 19 // user: %16
  %16 = enum $Optional<JSONError.JSONType>, #Optional.some!enumelt.1, %15 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:125, scope 11 // user: %17
  %17 = tuple $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>) (%10, %12, %16), loc "/source/Sources/JSONError.swift":140:76, scope 11 // user: %18
  %18 = enum $JSONError, #JSONError.missingOrInvalidType!enumelt.1, %17 : $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>), loc "/source/Sources/JSONError.swift":140:56, scope 11 // user: %19
  store %18 to %9 : $*JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // id: %19
  throw %8 : $Error, loc "/source/Sources/JSONError.swift":140:40, scope 3 // id: %20

bb4(%21 : $Bool):                                 // Preds: bb2
  %22 = enum $Optional<JSONError.JSONType>, #Optional.some!enumelt.1, %11 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:125, scope 11 // user: %23
  %23 = tuple $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>) (%10, %12, %22), loc "/source/Sources/JSONError.swift":140:76, scope 11 // user: %24
  %24 = enum $JSONError, #JSONError.missingOrInvalidType!enumelt.1, %23 : $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>), loc "/source/Sources/JSONError.swift":140:56, scope 11 // user: %25
  store %24 to %9 : $*JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // id: %25
  throw %8 : $Error, loc "/source/Sources/JSONError.swift":140:40, scope 3 // id: %26

bb5(%27 : $String):                               // Preds: bb2
  %28 = enum $JSONError.JSONType, #JSONError.JSONType.string!enumelt, loc "/source/Sources/JSONError.swift":115:35, scope 21 // user: %29
  %29 = enum $Optional<JSONError.JSONType>, #Optional.some!enumelt.1, %28 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:125, scope 11 // user: %30
  %30 = tuple $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>) (%10, %12, %29), loc "/source/Sources/JSONError.swift":140:76, scope 11 // user: %31
  %31 = enum $JSONError, #JSONError.missingOrInvalidType!enumelt.1, %30 : $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>), loc "/source/Sources/JSONError.swift":140:56, scope 11 // user: %32
  store %31 to %9 : $*JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // id: %32
  throw %8 : $Error, loc "/source/Sources/JSONError.swift":140:40, scope 3 // id: %33

bb6(%34 : $Int64):                                // Preds: bb2
  br bb7, loc "/source/Sources/JSONError.swift":116:13, scope 23 // id: %35

bb7:                                              // Preds: bb8 bb6
  %36 = enum $JSONError.JSONType, #JSONError.JSONType.number!enumelt, loc "/source/Sources/JSONError.swift":116:43, scope 25 // user: %37
  %37 = enum $Optional<JSONError.JSONType>, #Optional.some!enumelt.1, %36 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:125, scope 11 // user: %38
  %38 = tuple $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>) (%10, %12, %37), loc "/source/Sources/JSONError.swift":140:76, scope 11 // user: %39
  %39 = enum $JSONError, #JSONError.missingOrInvalidType!enumelt.1, %38 : $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>), loc "/source/Sources/JSONError.swift":140:56, scope 11 // user: %40
  store %39 to %9 : $*JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // id: %40
  throw %8 : $Error, loc "/source/Sources/JSONError.swift":140:40, scope 3 // id: %41

bb8(%42 : $Double):                               // Preds: bb2
  br bb7, loc "/source/Sources/JSONError.swift":116:13, scope 27 // id: %43

bb9(%44 : $DecimalPlaceholder):                   // Preds: bb2
  %45 = enum $JSONError.JSONType, #JSONError.JSONType.decimalPlaceholder!enumelt, loc "/source/Sources/JSONError.swift":121:29, scope 29 // user: %46
  %46 = enum $Optional<JSONError.JSONType>, #Optional.some!enumelt.1, %45 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:125, scope 11 // user: %47
  %47 = tuple $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>) (%10, %12, %46), loc "/source/Sources/JSONError.swift":140:76, scope 11 // user: %48
  %48 = enum $JSONError, #JSONError.missingOrInvalidType!enumelt.1, %47 : $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>), loc "/source/Sources/JSONError.swift":140:56, scope 11 // user: %49
  store %48 to %9 : $*JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // id: %49
  throw %8 : $Error, loc "/source/Sources/JSONError.swift":140:40, scope 3 // id: %50

bb10(%51 : $JSONObject):                          // Preds: bb2
  %52 = enum $JSONError.JSONType, #JSONError.JSONType.object!enumelt, loc "/source/Sources/JSONError.swift":123:35, scope 31 // user: %53
  %53 = enum $Optional<JSONError.JSONType>, #Optional.some!enumelt.1, %52 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:125, scope 11 // user: %54
  %54 = tuple $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>) (%10, %12, %53), loc "/source/Sources/JSONError.swift":140:76, scope 11 // user: %55
  %55 = enum $JSONError, #JSONError.missingOrInvalidType!enumelt.1, %54 : $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>), loc "/source/Sources/JSONError.swift":140:56, scope 11 // user: %56
  store %55 to %9 : $*JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // id: %56
  throw %8 : $Error, loc "/source/Sources/JSONError.swift":140:40, scope 3 // id: %57

bb11(%58 : $ContiguousArray<JSON>):               // Preds: bb2
  %59 = enum $JSONError.JSONType, #JSONError.JSONType.array!enumelt, loc "/source/Sources/JSONError.swift":124:34, scope 33 // user: %60
  %60 = enum $Optional<JSONError.JSONType>, #Optional.some!enumelt.1, %59 : $JSONError.JSONType, loc "/source/Sources/JSONError.swift":140:125, scope 11 // user: %61
  %61 = tuple $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>) (%10, %12, %60), loc "/source/Sources/JSONError.swift":140:76, scope 11 // user: %62
  %62 = enum $JSONError, #JSONError.missingOrInvalidType!enumelt.1, %61 : $(path: Optional<String>, expected: JSONError.ExpectedType, actual: Optional<JSONError.JSONType>), loc "/source/Sources/JSONError.swift":140:56, scope 11 // user: %63
  store %62 to %9 : $*JSONError, loc "/source/Sources/JSONError.swift":140:56, scope 11 // id: %63
  throw %8 : $Error, loc "/source/Sources/JSONError.swift":140:40, scope 3 // id: %64
} // end sil function '_TFO6PMJSON4JSON7getBoolfzT_Sb'

0  swift           0x000000000362f718
1  swift           0x000000000362fe56
2  libpthread.so.0 0x00007f10ebfbe390
3  libc.so.6       0x00007f10ea924428 gsignal + 56
4  libc.so.6       0x00007f10ea92602a abort + 362
5  swift           0x0000000000f2da13
6  swift           0x0000000000f2989e
7  swift           0x0000000000f2ca90
8  swift           0x000000000047f5b8
9  swift           0x000000000043b277
10 libc.so.6       0x00007f10ea90f830 __libc_start_main + 240
11 swift           0x00000000004386b9
Stack dump:
0.  Program arguments: /usr/bin/swift -frontend -c /source/Sources/Accessors.swift /source/Sources/DecimalNumber.swift /source/Sources/Decoder.swift /source/Sources/Encoder.swift /source/Sources/JSON.swift /source/Sources/JSONError.swift /source/Sources/JSONObject.swift /source/Sources/ObjectiveC.swift /source/Sources/Parser.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -I /source/.build/release -module-cache-path /source/.build/release/ModuleCache -D SWIFT_PACKAGE -emit-module-doc-path /source/.build/release/PMJSON.swiftdoc -O -parse-as-library -module-name PMJSON -emit-module-path /source/.build/release/PMJSON.swiftmodule -emit-dependencies-path /source/.build/release/PMJSON.build/PMJSON.d -num-threads 8 -o /source/.build/release/PMJSON.build/Accessors.swift.o -o /source/.build/release/PMJSON.build/DecimalNumber.swift.o -o /source/.build/release/PMJSON.build/Decoder.swift.o -o /source/.build/release/PMJSON.build/Encoder.swift.o -o /source/.build/release/PMJSON.build/JSON.swift.o -o /source/.build/release/PMJSON.build/JSONError.swift.o -o /source/.build/release/PMJSON.build/JSONObject.swift.o -o /source/.build/release/PMJSON.build/ObjectiveC.swift.o -o /source/.build/release/PMJSON.build/Parser.swift.o 
1.  While verifying SIL function @_TFO6PMJSON4JSON7getBoolfzT_Sb for 'getBool' at /source/Sources/JSONError.swift:139:5
<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): /usr/bin/swift-build-tool -f /source/.build/release.yaml

Metadata

Metadata

Assignees

Labels

LinuxPlatform: LinuxbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of software

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions