Skip to content

[SR-2320] swiftc segfaults on invalid method call on AnyObject #44927

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-2320
Radar None
Original Reporter der_fab (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee @slavapestov
Priority Medium

md5: 6dccaf55cdc99277fa7b6b8907e0ad6c

Issue Description:

The following code crashes swiftc when called with xcrun -sdk macosx swiftc Crash.swift

Crash.swift:

import Foundation

extension NSDictionary {
   func blub() throws {}
}

func test(a : AnyObject)
{
   try! a.blub()
}

Details:

> xcrun -sdk macosx swiftc Crash.swift 
0  swift                    0x0000000106ab866b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x0000000106ab7956 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000106ab8ccf SignalHandler(int) + 287
3  libsystem_platform.dylib 0x00007fff8bd2652a _sigtramp + 26
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 1949145840
5  swift                    0x00000001048ac03a swift::irgen::CallEmission::setArgs(swift::irgen::Explosion&, llvm::ArrayRef<swift::SILParameterInfo>, swift::irgen::WitnessMetadata*) + 3034
6  swift                    0x0000000104953a60 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 2736
7  swift                    0x000000010494123b swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9787
8  swift                    0x000000010489c5c8 swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 600
9  swift                    0x000000010492804e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1278
10 swift                    0x00000001049284f6 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 70
11 swift                    0x000000010480bc8c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 15004
12 swift                    0x000000010480768d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
13 swift                    0x00000001048030ac main + 1932
14 libdyld.dylib            0x00007fff8f72d5ad start + 1
15 libdyld.dylib            0x000000000000000f start + 1888299619
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file Crash.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name Crash -o /var/folders/y7/xcc17mnj6892fdqb4l7c0s6xrznjh4/T/Crash-d33749.o 
1.  While emitting IR SIL function @_TF5Crash4testFPs9AnyObject_T_ for 'test' at Crash.swift:7:1
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)

> swiftc --version
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
/projects/swiftc_bug (JIRA User)

XCode Version:
Version 7.3.1 (7D1014)

Metadata

Metadata

Assignees

Labels

SILGenArea → compiler: The SIL generation stagebugA 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