You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Important note: this issue can not be reproduced with the default toolchain bundled by Xcode 7.3.1, but it keeps crashing with our development build created from the swift-2.2.1-RELEASE tag.
Crash:
TYPE MISMATCH IN ARGUMENT 1 OF APPLY AT expression at [/Users/xavi/Desktop/SwiftCrashers/SwiftCrashers/SelfCrash.swift:11:23 - line:11:47] RangeText="unsafeBitCast(fake, self)"
argument value: %0 = argument of bb0 : $@thick B.Type // user: %1
parameter type: @thick Self.Type
0 swift 0x0000000109ace74b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x0000000109acda36 llvm::sys::RunSignalHandlers() + 70
2 swift 0x0000000109aced1f SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fff9afb352a _sigtramp + 26
4 swift 0x000000010a3da315 FirstTarget + 66429
5 swift 0x0000000109acebe6 abort + 22
6 swift 0x000000010790811a swift::Lowering::SILGenFunction::emitApply(swift::SILLocation, swift::Lowering::ManagedValue, llvm::ArrayRef<swift::Substitution>, llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::ApplyOptions, llvm::Optional<swift::SILFunctionTypeRepresentation>, llvm::Optional<swift::ForeignErrorConvention> const&, swift::Lowering::SGFContext) + 6426
7 swift 0x000000010790ae13 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 5875
8 swift 0x00000001079091da swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 58
9 swift 0x000000010794cd36 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 86
10 swift 0x00000001079476ac swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 316
11 swift 0x0000000107937d55 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 213
12 swift 0x0000000107937e4d swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*) + 45
13 swift 0x000000010799f576 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 550
14 swift 0x000000010799f345 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
15 swift 0x0000000107961521 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 353
16 swift 0x00000001078fa2b3 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 1155
17 swift 0x00000001079a4d61 (anonymous namespace)::SILGenType::emitType() + 1409
18 swift 0x00000001079a475e swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
19 swift 0x00000001078fea9b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 683
20 swift 0x00000001078ffb30 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 848
21 swift 0x0000000107900055 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 117
22 swift 0x000000010767a937 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 13783
23 swift 0x0000000107676523 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2803
24 swift 0x000000010767146c main + 1532
25 libdyld.dylib 0x00007fff969275ad start + 1
26 libdyld.dylib 0x000000000000003c start + 1768786576
class A {
}
class B {
static func fake() -> Self {
let fake = A()
let bitcast = unsafeBitCast(fake, to: self)
return bitcast
}
}
Output:
TYPE MISMATCH IN ARGUMENT 1 OF APPLY AT expression at [<stdin>:9:23 - line:9:51] RangeText="unsafeBitCast(fake, to: self)"
argument value: %0 = argument of bb0 : $@thick B.Type // user: %1
parameter type: @thick Self.Type
The snippet I posted is a simplified version of code that we use to fake dependencies in our test target, and it's is intended to crash if we interact with the returned object. In its original form it's an extension of NSObject that looks like this:
extensionNSObject {
// WARNING: It creates a fake object to fill dependencies that are NOT going to be used. Otherwise it will crash/staticfuncfake() -> Self {
returnunsafeBitCast(OCMockObject.mockForClass(selfas! AnyClass), self)
}
}
Thanks for the warning, hope this makes more sense now 🙂
Environment
Xcode 7.3.1 (7D1014), Local Swift Development Snapshot built from "swift-2.2.1-RELEASE" tag.
Additional Detail from JIRA
md5: cdebbe25fbf8772e2cb3a55cbb4eb764
Issue Description:
Compiler crashes in the CompileSwift step while building the following code:
Important note: this issue can not be reproduced with the default toolchain bundled by Xcode 7.3.1, but it keeps crashing with our development build created from the swift-2.2.1-RELEASE tag.
Crash:
Stack dump:
The text was updated successfully, but these errors were encountered: