[swift-users] stack trace of Swift executable

Josh Parmenter jparmenter at vectorform.com
Fri Apr 28 18:28:47 CDT 2017


Thanks for articulating this. It is something I have also found somewhat frustrating.

Is there anything that could be done to make swift stack traces more informative? Obj-C traces were very clear. I’d love to get back to that level again.
Best,
Josh



Joshua Parmenter | Software Development

T 248 777 7777
C 206 437 1551
F 248 616 1980
www.vectorform.com<http://www.vectorform.com/>

Vectorform
2107 Elliott Ave Suite 303
Seattle, WA  98121 USA

Think Tank. Lab. Studio.
We invent digital products and experiences.

SEATTLE | DETROIT | NEW YORK | MUNICH | HYDERABAD

On Apr 28, 2017, at 2:28 PM, Nick Snyder via swift-users <swift-users at swift.org<mailto:swift-users at swift.org>> wrote:

I have a simple main.swift that looks like this:

```
print("Hello, world!")
let x: String? = nil

func say(message: String?) {
    print(x!) // intentional crash
}

say(message: x)
```

Running this results in the crash

```
$ swift build && ./.build/debug/hello
Hello, world!
fatal error: unexpectedly found nil while unwrapping an Optional value
Current stack trace:
0    libswiftCore.dylib                 0x0000000110120130 swift_reportError + 129
1    libswiftCore.dylib                 0x000000011013cb50 _swift_stdlib_reportFatalError + 60
2    libswiftCore.dylib                 0x000000010ff2d250 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 342
3    libswiftCore.dylib                 0x00000001100a7e90 partial apply for (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #2) + 109
4    libswiftCore.dylib                 0x000000010ff2d250 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 342
5    libswiftCore.dylib                 0x000000011005a9a0 specialized _fatalErrorMessage(StaticString, StaticString, file : StaticString, line : UInt, flags : UInt32) -> Never + 96
6    hello                              0x000000010fee6200 main + 345
7    libdyld.dylib                      0x00007fffe0375234 start + 1
Illegal instruction: 4
```

From the crash, how do I map back line 6 to an actual line in main.swift?
_______________________________________________
swift-users mailing list
swift-users at swift.org<mailto:swift-users at swift.org>
https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list