• Emmanuel Odeke's avatar
    runtime: print signal name in panic, if name is known · 1a7fc235
    Emmanuel Odeke authored
    Adds a small function signame that infers a signal name
    from the signal table, otherwise will fallback to using
    hex(sig) as previously. No signal table is present for
    Windows hence it will always print the hex value.
    
    Sample code and new result:
    ```go
    package main
    
    import (
      "fmt"
      "time"
    )
    
    func main() {
      defer func() {
        if err := recover(); err != nil {
          fmt.Printf("err=%v\n", err)
        }
      }()
    
      ticker := time.Tick(1e9)
      for {
        <-ticker
      }
    }
    ```
    
    ```shell
    $ go run main.go &
    $ kill -11 <pid>
    fatal error: unexpected signal during runtime execution
    [signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e
    pc=0xc71db]
    ...
    ```
    
    Fixes #13969
    
    Change-Id: Ie6be312eb766661f1cea9afec352b73270f27f9d
    Reviewed-on: https://go-review.googlesource.com/22753Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    1a7fc235
os1_nacl.go 5.28 KB