Re: [swift-users] stack trace of Swift executable

2017-05-04 Thread Greg Parker via swift-users
The stack trace printed by the process will never include file and line 
numbers. Swift and ObjC work the same way here.

You want to find the crash report generated by the OS. Either it will have file 
and line numbers already, or it will contain enough information to look up the 
file and line numbers after the fact (part of a process called "symbolication").


> On May 3, 2017, at 2:47 AM, Alex Blewitt  wrote:
> 
> Greg,
> 
> This occurs when compiled with swiftc -g as well. In fact, I think 'swift 
> build', when run by default, will compile with swiftc -g. It's only when you 
> run 'swift build --configuration release' that it will compile without it.
> 
> $ swiftc --version
> Apple Swift version 3.1 (swift-3.1.1-RELEASE)
> Target: x86_64-apple-macosx10.9
> $ swiftc -g main.swift
> $ ./main
> Hello, world!
> fatal error: unexpectedly found nil while unwrapping an Optional value
> Current stack trace:
> 0libswiftCore.dylib 0x00010edc7160 swift_reportError 
> + 125
> 1libswiftCore.dylib 0x00010ede3ac0 
> _swift_stdlib_reportFatalError + 60
> 2libswiftCore.dylib 0x00010ebd4260 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 3libswiftCore.dylib 0x00010ed4f120 partial apply for 
> (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never).(closure #2) + 109
> 4libswiftCore.dylib 0x00010ebd4260 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 5libswiftCore.dylib 0x00010ed01d00 specialized 
> _fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never + 96
> 6main   0x00010eb91340 say(message : 
> String?) -> () + 248
> 7main   0x00010eb911e0 main + 328
> 8libdyld.dylib  0x7fffb444d234 start + 1
> Illegal instruction: 4
> 
> Note that lldb can symbolicate the result and identify the return value, by 
> looking at the backtrace:
> 
> $ lldb main
> (lldb) target create "main"
> Current executable set to 'main' (x86_64).
> (lldb) run
> Process 33032 launched: '/tmp/main' (x86_64)
> Hello, world!
> fatal error: unexpectedly found nil while unwrapping an Optional value
> 2017-05-03 10:41:17.340963+0100 main[33032:55100807] fatal error: 
> unexpectedly found nil while unwrapping an Optional value
> Current stack trace:
> 0libswiftCore.dylib 0x0001002c1160 swift_reportError 
> + 125
> 1libswiftCore.dylib 0x0001002ddac0 
> _swift_stdlib_reportFatalError + 60
> 2libswiftCore.dylib 0x0001000ce260 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 3libswiftCore.dylib 0x000100249120 partial apply for 
> (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never).(closure #2) + 109
> 4libswiftCore.dylib 0x0001000ce260 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 5libswiftCore.dylib 0x0001001fbd00 specialized 
> _fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never + 96
> 6main   0x00011340 say(message : 
> String?) -> () + 248
> 7main   0x000111e0 main + 328
> 8libdyld.dylib  0x7fffb444d234 start + 1
> Process 33032 stopped
> * thread #1, queue = 'com.apple.main-thread', stop reason = 
> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
> frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
> specialization  
> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
> Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never + 
> 96
> libswiftCore.dylib`function signature specialization  attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage 
> (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : 
> Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
> ->  0x1001fbd60 <+96>: ud2
> 0x1001fbd62 <+98>: nopw   %cs:(%rax,%rax)
> 
> libswiftCore.dylib`protocol witness table accessor for  
> Swift.AnySequence : Swift.Sequence in Swift:
> 0x1001fbd70 <+0>:  pushq  %rbp
> 0x1001fbd71 <+1>:  movq   %rsp, %rbp
> (lldb) bt
> * thread #1, queue = 'com.apple.main-thread', stop reason = 
> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
>   * frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
> specialization  
> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
> Swift.StaticString

Re: [swift-users] stack trace of Swift executable

2017-05-03 Thread Alex Blewitt via swift-users
Greg,

This occurs when compiled with swiftc -g as well. In fact, I think 'swift 
build', when run by default, will compile with swiftc -g. It's only when you 
run 'swift build --configuration release' that it will compile without it.

$ swiftc --version
Apple Swift version 3.1 (swift-3.1.1-RELEASE)
Target: x86_64-apple-macosx10.9
$ swiftc -g main.swift
$ ./main
Hello, world!
fatal error: unexpectedly found nil while unwrapping an Optional value
Current stack trace:
0libswiftCore.dylib 0x00010edc7160 swift_reportError + 
125
1libswiftCore.dylib 0x00010ede3ac0 
_swift_stdlib_reportFatalError + 60
2libswiftCore.dylib 0x00010ebd4260 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
3libswiftCore.dylib 0x00010ed4f120 partial apply for 
(_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never).(closure #2) + 109
4libswiftCore.dylib 0x00010ebd4260 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
5libswiftCore.dylib 0x00010ed01d00 specialized 
_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never + 96
6main   0x00010eb91340 say(message : 
String?) -> () + 248
7main   0x00010eb911e0 main + 328
8libdyld.dylib  0x7fffb444d234 start + 1
Illegal instruction: 4

Note that lldb can symbolicate the result and identify the return value, by 
looking at the backtrace:

$ lldb main
(lldb) target create "main"
Current executable set to 'main' (x86_64).
(lldb) run
Process 33032 launched: '/tmp/main' (x86_64)
Hello, world!
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-05-03 10:41:17.340963+0100 main[33032:55100807] fatal error: unexpectedly 
found nil while unwrapping an Optional value
Current stack trace:
0libswiftCore.dylib 0x0001002c1160 swift_reportError + 
125
1libswiftCore.dylib 0x0001002ddac0 
_swift_stdlib_reportFatalError + 60
2libswiftCore.dylib 0x0001000ce260 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
3libswiftCore.dylib 0x000100249120 partial apply for 
(_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never).(closure #2) + 109
4libswiftCore.dylib 0x0001000ce260 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
5libswiftCore.dylib 0x0001001fbd00 specialized 
_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never + 96
6main   0x00011340 say(message : 
String?) -> () + 248
7main   0x000111e0 main + 328
8libdyld.dylib  0x7fffb444d234 start + 1
Process 33032 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION 
(code=EXC_I386_INVOP, subcode=0x0)
frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
specialization  of 
Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never + 96
libswiftCore.dylib`function signature specialization  of Swift._fatalErrorMessage 
(Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : 
Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
->  0x1001fbd60 <+96>: ud2
0x1001fbd62 <+98>: nopw   %cs:(%rax,%rax)

libswiftCore.dylib`protocol witness table accessor for  Swift.AnySequence 
: Swift.Sequence in Swift:
0x1001fbd70 <+0>:  pushq  %rbp
0x1001fbd71 <+1>:  movq   %rsp, %rbp
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION 
(code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
specialization  of 
Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never + 96
frame #1: 0x00011438 main`say(message=nil) -> () at main.swift:5
frame #2: 0x00011328 main`main at main.swift:8
frame #3: 0x7fffb444d235 libdyld.dylib`start + 1
frame #4: 0x7fffb444d235 libdyld.dylib`start + 1

I suspect this is because Swift is generating a .dSYM which is read by LLDB but 
either not read or not loaded by the swift runtime when producing the backtrace:

$ find .
.
./main
./main.dSYM
./main.dSYM/Contents
./main.dSYM/Contents/Info.plist
./main.dSYM/Contents/Resources
./main.dSYM/Contents/Resources/DWARF
./main.dSYM/Contents/R

Re: [swift-users] stack trace of Swift executable

2017-05-02 Thread Greg Parker via swift-users
That doesn't look symbolicated. If it were symbolicated, and the build used -g, 
you would have a file and line number for the main+345 frame.


> On May 2, 2017, at 2:31 PM, Nick Snyder via swift-users 
>  wrote:
> 
> In practice, I would need the stack trace first to figure out how to 
> reproduce the issue, so lldb doesn't really help.
> 
> How would I go about symbolicating this further on macOS (Xcode or otherwise)?
> 
> From reading the docs it seems like the crash report I get is already 
> completely symbolicated:
> https://developer.apple.com/library/content/technotes/tn2151/_index.html#//apple_ref/doc/uid/DTS40008184-CH1-SYMBOLICATION-_DETERMINING_WHETHER_A_CRASH_REPORT_IS_SYMBOLICATED
>  
> 
> 
> On Tue, May 2, 2017 at 1:21 AM, Alex Blewitt  > wrote:
> If you can reproduce it, and run it under lldb, it will print the source line 
> for you:
> 
> $ lldb .build/debug/main
> (lldb) target create ".build/debug/main"
> ruCurrent executable set to '.build/debug/main' (x86_64).
> (lldb) run
> Process 19013 launched: '/private/tmp/main/.build/debug/main' (x86_64)
> Hello, world!
> fatal error: unexpectedly found nil while unwrapping an Optional value
> 2017-05-02 09:17:11.351608+0100 asdf[19013:54205130] fatal error: 
> unexpectedly found nil while unwrapping an Optional value
> Current stack trace:
> 0libswiftCore.dylib 0x0001002c1160 swift_reportError 
> + 125
> 1libswiftCore.dylib 0x0001002ddac0 
> _swift_stdlib_reportFatalError + 60
> 2libswiftCore.dylib 0x0001000ce260 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 3libswiftCore.dylib 0x000100249120 partial apply for 
> (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never).(closure #2) + 109
> 4libswiftCore.dylib 0x0001000ce260 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 5libswiftCore.dylib 0x0001001fbd00 specialized 
> _fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never + 96
> 6main   0x00011340 say(message : 
> String?) -> () + 248
> 7main   0x000111e0 main + 328
> 8libdyld.dylib  0x7fffb444d234 start + 1
> Process 19013 stopped
> * thread #1, queue = 'com.apple.main-thread', stop reason = 
> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
> frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
> specialization  
> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
> Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never + 
> 96
> libswiftCore.dylib`function signature specialization  attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage 
> (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : 
> Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
> ->  0x1001fbd60 <+96>: ud2
> 0x1001fbd62 <+98>: nopw   %cs:(%rax,%rax)
> 
> libswiftCore.dylib`protocol witness table accessor for  
> Swift.AnySequence : Swift.Sequence in Swift:
> 0x1001fbd70 <+0>:  pushq  %rbp
> 0x1001fbd71 <+1>:  movq   %rsp, %rbp
> 
> (lldb) bt
> * thread #1, queue = 'com.apple.main-thread', stop reason = 
> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
>   * frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
> specialization  
> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
> Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never + 
> 96
> frame #1: 0x00011438 main`say(message=nil) -> () at main.swift:5
> frame #2: 0x00011328 main`main at main.swift:8
> frame #3: 0x7fffb444d235 libdyld.dylib`start + 1
> frame #4: 0x7fffb444d235 libdyld.dylib`start + 1
> 
> There is a symbolication tool available for Linux in the 
> ~/swift/utils/symbolicate-linux-fatal, and Xcode can do the same 
> symbolication for you as well.
> 
> Alex
> 
>> On 28 Apr 2017, at 22:28, Nick Snyder via swift-users > > 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:
>> 0libswiftCore.dylib  

Re: [swift-users] stack trace of Swift executable

2017-05-02 Thread Nick Snyder via swift-users
In practice, I would need the stack trace first to figure out how to
reproduce the issue, so lldb doesn't really help.

How would I go about symbolicating this further on macOS (Xcode or
otherwise)?

>From reading the docs it seems like the crash report I get is already
completely symbolicated:
https://developer.apple.com/library/content/technotes/tn2151/_index.html#//apple_ref/doc/uid/DTS40008184-CH1-SYMBOLICATION-_DETERMINING_WHETHER_A_CRASH_REPORT_IS_SYMBOLICATED

On Tue, May 2, 2017 at 1:21 AM, Alex Blewitt  wrote:

> If you can reproduce it, and run it under lldb, it will print the source
> line for you:
>
> $ lldb .build/debug/main
> (lldb) target create ".build/debug/main"
> ruCurrent executable set to '.build/debug/main' (x86_64).
> (lldb) run
> Process 19013 launched: '/private/tmp/main/.build/debug/main' (x86_64)
> Hello, world!
> fatal error: unexpectedly found nil while unwrapping an Optional value
> 2017-05-02 09:17:11.351608+0100 asdf[19013:54205130] fatal error:
> unexpectedly found nil while unwrapping an Optional value
> Current stack trace:
> 0libswiftCore.dylib 0x0001002c1160
> swift_reportError + 125
> 1libswiftCore.dylib 0x0001002ddac0
> _swift_stdlib_reportFatalError + 60
> 2libswiftCore.dylib 0x0001000ce260 specialized
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) ->
> A) -> A + 342
> 3libswiftCore.dylib 0x000100249120 partial apply
> for (_fatalErrorMessage(StaticString, StaticString, file : StaticString,
> line : UInt, flags : UInt32) -> Never).(closure #2) + 109
> 4libswiftCore.dylib 0x0001000ce260 specialized
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) ->
> A) -> A + 342
> 5libswiftCore.dylib 0x0001001fbd00 specialized
> _fatalErrorMessage(StaticString, StaticString, file : StaticString, line
> : UInt, flags : UInt32) -> Never + 96
> 6main   0x00011340 say(message :
> String?) -> () + 248
> 7main   0x000111e0 main + 328
> 8libdyld.dylib  0x7fffb444d234 start + 1
> Process 19013 stopped
> * thread #1, queue = 'com.apple.main-thread', stop reason =
> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
> frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature
> specialization 
> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file :
> Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never
> + 96
> libswiftCore.dylib`function signature specialization  attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage
> (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line :
> Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
> ->  0x1001fbd60 <+96>: ud2
> 0x1001fbd62 <+98>: nopw   %cs:(%rax,%rax)
>
> libswiftCore.dylib`protocol witness table accessor for 
> Swift.AnySequence : Swift.Sequence in Swift:
> 0x1001fbd70 <+0>:  pushq  %rbp
> 0x1001fbd71 <+1>:  movq   %rsp, %rbp
>
> (lldb) bt
> * thread #1, queue = 'com.apple.main-thread', stop reason =
> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
>   * frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature
> specialization 
> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file :
> Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never
> + 96
> *frame #1: 0x00011438 main`say(message=nil) -> () at
> main.swift:5*
> *frame #2: 0x00011328 main`main at main.swift:8*
> frame #3: 0x7fffb444d235 libdyld.dylib`start + 1
> frame #4: 0x7fffb444d235 libdyld.dylib`start + 1
>
> There is a symbolication tool available for Linux in the
> ~/swift/utils/symbolicate-linux-fatal, and Xcode can do the same
> symbolication for you as well.
>
> Alex
>
> On 28 Apr 2017, at 22:28, Nick Snyder via swift-users <
> swift-users@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:
> 0libswiftCore.dylib 0x000110120130
> swift_reportError + 129
> 1libswiftCore.dylib 0x00011013cb50
> _swift_stdlib_reportFatalError + 60
> 2libswiftCore.dylib 0x00010ff2d250 specialized
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) ->
> A) -> A + 342
> 3libswiftCore.dylib 0x0001100a7e90 partial apply
> for (_fatalErrorMessage(StaticString, StaticString, file : StaticString,
> line : UInt, flags : UInt32) -> Never).(closure #2) + 1

Re: [swift-users] stack trace of Swift executable

2017-05-02 Thread Alex Blewitt via swift-users
If you can reproduce it, and run it under lldb, it will print the source line 
for you:

$ lldb .build/debug/main
(lldb) target create ".build/debug/main"
ruCurrent executable set to '.build/debug/main' (x86_64).
(lldb) run
Process 19013 launched: '/private/tmp/main/.build/debug/main' (x86_64)
Hello, world!
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-05-02 09:17:11.351608+0100 asdf[19013:54205130] fatal error: unexpectedly 
found nil while unwrapping an Optional value
Current stack trace:
0libswiftCore.dylib 0x0001002c1160 swift_reportError + 
125
1libswiftCore.dylib 0x0001002ddac0 
_swift_stdlib_reportFatalError + 60
2libswiftCore.dylib 0x0001000ce260 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
3libswiftCore.dylib 0x000100249120 partial apply for 
(_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never).(closure #2) + 109
4libswiftCore.dylib 0x0001000ce260 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
5libswiftCore.dylib 0x0001001fbd00 specialized 
_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never + 96
6main   0x00011340 say(message : 
String?) -> () + 248
7main   0x000111e0 main + 328
8libdyld.dylib  0x7fffb444d234 start + 1
Process 19013 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION 
(code=EXC_I386_INVOP, subcode=0x0)
frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
specialization  of 
Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never + 96
libswiftCore.dylib`function signature specialization  of Swift._fatalErrorMessage 
(Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : 
Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
->  0x1001fbd60 <+96>: ud2
0x1001fbd62 <+98>: nopw   %cs:(%rax,%rax)

libswiftCore.dylib`protocol witness table accessor for  Swift.AnySequence 
: Swift.Sequence in Swift:
0x1001fbd70 <+0>:  pushq  %rbp
0x1001fbd71 <+1>:  movq   %rsp, %rbp

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION 
(code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x0001001fbd60 libswiftCore.dylib`function signature 
specialization  of 
Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : 
Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never + 96
frame #1: 0x00011438 main`say(message=nil) -> () at main.swift:5
frame #2: 0x00011328 main`main at main.swift:8
frame #3: 0x7fffb444d235 libdyld.dylib`start + 1
frame #4: 0x7fffb444d235 libdyld.dylib`start + 1

There is a symbolication tool available for Linux in the 
~/swift/utils/symbolicate-linux-fatal, and Xcode can do the same symbolication 
for you as well.

Alex

> On 28 Apr 2017, at 22:28, Nick Snyder via swift-users  
> 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:
> 0libswiftCore.dylib 0x000110120130 swift_reportError 
> + 129
> 1libswiftCore.dylib 0x00011013cb50 
> _swift_stdlib_reportFatalError + 60
> 2libswiftCore.dylib 0x00010ff2d250 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 3libswiftCore.dylib 0x0001100a7e90 partial apply for 
> (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never).(closure #2) + 109
> 4libswiftCore.dylib 0x00010ff2d250 specialized 
> specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> 
> A) -> A + 342
> 5libswiftCore.dylib 0x00011005a9a0 specialized 
> _fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
> UInt, flags : UInt32) -> Never + 96
> 6hello  0x00010fee6200 main + 345
> 7libdyld.dylib  0x7fffe0375234 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-

Re: [swift-users] stack trace of Swift executable

2017-04-28 Thread Josh Parmenter via swift-users
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 
C 206 437 1551
F 248 616 1980
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 
mailto:swift-users@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:
0libswiftCore.dylib 0x000110120130 swift_reportError + 
129
1libswiftCore.dylib 0x00011013cb50 
_swift_stdlib_reportFatalError + 60
2libswiftCore.dylib 0x00010ff2d250 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
3libswiftCore.dylib 0x0001100a7e90 partial apply for 
(_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never).(closure #2) + 109
4libswiftCore.dylib 0x00010ff2d250 specialized 
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) 
-> A + 342
5libswiftCore.dylib 0x00011005a9a0 specialized 
_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : 
UInt, flags : UInt32) -> Never + 96
6hello  0x00010fee6200 main + 345
7libdyld.dylib  0x7fffe0375234 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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] stack trace of Swift executable

2017-04-28 Thread Nick Snyder via swift-users
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:
0libswiftCore.dylib 0x000110120130
swift_reportError + 129
1libswiftCore.dylib 0x00011013cb50
_swift_stdlib_reportFatalError + 60
2libswiftCore.dylib 0x00010ff2d250 specialized
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) ->
A) -> A + 342
3libswiftCore.dylib 0x0001100a7e90 partial apply
for (_fatalErrorMessage(StaticString, StaticString, file : StaticString,
line : UInt, flags : UInt32) -> Never).(closure #2) + 109
4libswiftCore.dylib 0x00010ff2d250 specialized
specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) ->
A) -> A + 342
5libswiftCore.dylib 0x00011005a9a0 specialized
_fatalErrorMessage(StaticString, StaticString, file : StaticString, line :
UInt, flags : UInt32) -> Never + 96
6hello  0x00010fee6200 main + 345
7libdyld.dylib  0x7fffe0375234 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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users