Skip to content

[SR-396] Compiler crash casting [NSObject:AnyObject] to [NSString:NSString] #43013

Open

Description

@swift-ci
Previous ID SR-396
Radar None
Original Reporter joeiachievedit (JIRA User)
Type Bug
Environment

Ubuntu 14.04

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

md5: cd6ad512b6141942a402a8552e07d31d

Issue Description:

swiftc crashes on the following code where I am attempting to cast an NSNotification userInfo dictionary to an [NSString:NSString]

import Foundation

let INPUT_NOTIFICATION = "InputNotification"
let nc = NSNotificationCenter.defaultCenter()

nc.addObserverForName(INPUT_NOTIFICATION, object:nil, queue:nil) {
  (notification) in
  let userInfo = notification.userInfo as! [NSString:NSString]
}
swiftc swift_crash.swift   
0  swift           0x0000000002f3a348 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift           0x0000000002f38b16 llvm::sys::RunSignalHandlers() + 54
2  swift           0x0000000002f3ae7a
3  libpthread.so.0 0x00007f9dfe2a8340
4  swift           0x0000000000988d9b
5  swift           0x000000000098870b swift::Lowering::emitUnconditionalCheckedCast(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Expr*, swift::Type, swift::CheckedCastKind, swift::Lowering::SGFContext) + 139
6  swift           0x00000000009944c9
7  swift           0x000000000098c949
8  swift           0x000000000097d320
9  swift           0x000000000097d40d
10 swift           0x00000000009d1b17
11 swift           0x00000000009d193e
12 swift           0x00000000009a598e
13 swift           0x00000000009407f5
14 swift           0x000000000099f1fa
15 swift           0x0000000000991b6e
16 swift           0x000000000098ca84
17 swift           0x0000000000959b9b
18 swift           0x000000000095ac15
19 swift           0x000000000095984b
20 swift           0x0000000000958fa4
21 swift           0x000000000094c79b
22 swift           0x000000000094b1b3
23 swift           0x0000000000991b2e
24 swift           0x000000000099083c
25 swift           0x0000000000943bb9
26 swift           0x000000000094444b
27 swift           0x0000000000945162 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 498
28 swift           0x00000000009456d6 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 118
29 swift           0x0000000000766690
30 swift           0x0000000000761e62 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2482
31 swift           0x000000000075ca41 main + 2705
32 libc.so.6       0x00007f9dfd4a9ec5 __libc_start_main + 245
33 swift           0x000000000075bebd
Stack dump:
0.  Program arguments: /usr/bin/swift -frontend -c -primary-file swift_crash.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name swift_crash -o /tmp/swift_crash-dea395.o 
1.  While silgen closureexpr SIL function @_TF11swift_crashU_FC10Foundation14NSNotificationT_ for expression at [swift_crash.swift:6:66 - line:9:1] RangeText="{
  (notification) in
  let userInfo = notification.userInfo as! [NSString:NSString]
}"
<unknown>:0: error: unable to execute command: Segmentation fault
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)

Activity

  1. gottesmm commented on Dec 28, 2015

    @gottesmm
    Contributor

    This is a SILGen crasher.

  2. Dante-Broggi commented on Aug 31, 2018

    @Dante-Broggi
    Contributor

    I think this can be closed, The provided code no longer crashes in the Xcode 9.4.1 toolchain.

  3. added
    crashBug: A crash, i.e., an abnormal termination of software
    on Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    LinuxPlatform: LinuxSILGenArea → 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