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-2265] SIL Verification Failed: Source value should be an object value #44872

Closed
swift-ci opened this issue Aug 3, 2016 · 6 comments
Closed
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 optimized only Flag: An issue whose reproduction requires optimized compilation regression swift 3.0

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Aug 3, 2016

Previous ID SR-2265
Radar None
Original Reporter mattgallagher (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Code compiled using the following command-line:

./swiftc -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O /Users/matt/Desktop/Send/Send/main.swift

Tests performed on Mac OS X 10.11 running Xcode 8 beta 4 and a debug version of Swift built from github (commit 9ee231e) using "utils/build-script -x".

Closest analogue under Swift 2.3 has no problems (although it's not an apples-to-apples comparison).

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

md5: 7c4e67728456be6984ac79a43dfd9191

Issue Description:

The following code:

import Swift

enum Data<T> {
   case value(T)
   case error(Error)
}

class TestClass<T> {
   var childClass = TestClass<Bool>()
   func perform(data: Data<T>) {
      childClass.perform(data: .value(false))
   }
}

let t = TestClass<Bool>()
t.perform(data: .value(true))

placed in a typical "main.swift" file and compiled with "-O" optimizations will segfault swiftlang-800.0.41.2 (Xcode beta 4) and will give the following error in Swift built from latest source (commit 9ee231e):

SIL verification failed: Source value should be an object value: I->getOperand()->getType().isObject()
Verifying instruction:
     %24 = alloc_stack $Data<Bool>, loc "/Users/matt/Desktop/Send/Send/main.swift":18:32, scope 0 // users: %29, %31, %25
->   release_value %24 : $*Data<Bool>, scope 0    // id: %29
In function:
sil_scope 1 { loc "/Users/matt/Desktop/Send/Send/main.swift":16:7 parent @_TTSf4d_n___TTSg5Sb___TFC4main9TestClass7performfT4dataGOS_4Datax__T_ : $@convention(method) (@guaranteed TestClass<Bool>) -> () }
sil_scope 2 { loc "/Users/matt/Desktop/Send/Send/main.swift":19:2 parent 1 }
sil_scope 3 { loc "/Users/matt/Desktop/Send/Send/main.swift":16:7 parent @_TTSg5Sb___TFC4main9TestClass7performfT4dataGOS_4Datax__T_ : $@convention(method) (@owned Data<Bool>, @guaranteed TestClass<Bool>) -> () }
sil_scope 4 { loc "/Users/matt/Desktop/Send/Send/main.swift":18:33 parent 2 }
sil_scope 5 { loc "/Users/matt/Desktop/Send/Send/main.swift":16:7 parent 3 inlined_at 4 }

There's a few variations on the same problem, which probably have the same underlying cause. Including this one:

import Swift
import Dispatch

class TestClass<T> {
   var mutex = DispatchQueue(label: "")
   var childClass: TestClass<Bool>? = nil
   
   func perform(data: Data<T>) {
      let child = mutex.sync { () -> TestClass<Bool>? in
         if case .error = data {
            return self.childClass
         } else {
            return nil
         }
      }
      
      child?.perform(data: .value(false))
   }
}

enum Data<T> {
   case value(T)
   case error(Error)
}

let t = TestClass<Int>()
t.perform(data: .value(0))

which gives the slightly different verification error:

SIL verification failed: operand of 'apply' doesn't match function input type
  $*Data<Bool>
  $Data<Bool>
Verifying instruction:
     %26 = unchecked_enum_data %20 : $Optional<TestClass<Bool>>, #Optional.some!enumelt.1, loc "/Users/matt/Desktop/Send/Send/main.swift":25:8, scope 0 // user: %33
     %29 = alloc_stack $Data<Bool>, loc "/Users/matt/Desktop/Send/Send/main.swift":25:36, scope 0 // users: %35, %33, %30
     // function_ref specialized TestClass.perform(data : Data<A>) -> ()
  %31 = function_ref @_TTSg5Sb___TFC4main9TestClass7performfT4dataGOS_4Datax__T_ : $@convention(method) (@owned Data<Bool>, @guaranteed TestClass<Bool>) -> (), loc "/Users/matt/Desktop/Send/Send/main.swift":25:37, scope 0 // user: %33
->   %33 = apply %31(%29, %26) : $@convention(method) (@owned Data<Bool>, @guaranteed TestClass<Bool>) -> (), loc "/Users/matt/Desktop/Send/Send/main.swift":25:37, scope 0
In function:
sil_scope 1 { loc "/Users/matt/Desktop/Send/Send/main.swift":16:7 parent @_TTSg5Sb___TFC4main9TestClass7performfT4dataGOS_4Datax__T_ : $@convention(method) (@owned Data<Bool>, @guaranteed TestClass<Bool>) -> () }
sil_scope 2 { loc "/Users/matt/Desktop/Send/Send/main.swift":26:2 parent 1 }
@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 3, 2016

Comment by Matt Gallagher (JIRA)

I've removed some extraneous code from the first example.

@belkadan
Copy link
Contributor

belkadan commented Aug 3, 2016

I'm getting an infinite loop somewhere in the compiler even without -O.

@belkadan
Copy link
Contributor

belkadan commented Aug 3, 2016

…and it doesn't seem to be a regression.

@belkadan
Copy link
Contributor

belkadan commented Aug 3, 2016

Though maybe it only happens in debug builds.

@slavapestov
Copy link
Member

Can't reproduce crash in 3.0 or master.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jan 1, 2017

Comment by Matt Gallagher (JIRA)

Confirm from my end that this no longer occurs on 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 optimized only Flag: An issue whose reproduction requires optimized compilation regression swift 3.0
Projects
None yet
Development

No branches or pull requests

4 participants