2017-09-02 5 views
4

Le code suivant se bloquer sur mon mac après avoir couru 2 ou 3 secondes, mais ça va sur le centos 7, et, je suis sur aller 1.6.3.golang log.Printf crash

Questions:

  1. Ce qui a causé cette chute?
  2. Comment l'éviter? (Ne pas en récupérer)
  3. Que signifient les arguments de la pile suivante?

    log.Printf(0x1068d8, 0x6, 0x0, 0x0, 0x0) 
    

    la signature est:

    Print(v ...interface{}) 
    

Le écrasé code:

package main 
import (
    "log" 
) 

func main() { 
    for { 
     log.Printf("hello") 
    } 
} 

Il va planter en 10 secondes et imprime:

2017/09/02 21:50:01 hello 
2017/09/02 21:50:01 hello 
2017/09/02 21:50:01 hello 
2017/09/02 21:50:01 hello 
fatal error: unexpected signal during runtime execution 
[signal 0xb code=0x1 addr=0x1777d0d1d11 pc=0x92f60] 

goroutine 1 [running]: 
runtime.throw(0x12c000, 0x2a) 
    /usr/local/Cellar/go/1.6.3/libexec/src/runtime/panic.go:547 +0x90 fp=0xc820035da0 sp=0xc820035d88 
runtime.sigpanic() 
    /usr/local/Cellar/go/1.6.3/libexec/src/runtime/sigpanic_unix.go:12 +0x5a fp=0xc820035df0 sp=0xc820035da0 
sync.(*Pool).Get(0x1991e0, 0x0, 0x0) 
    /usr/local/Cellar/go/1.6.3/libexec/src/sync/pool.go:102 +0x40 fp=0xc820035e40 sp=0xc820035df0 
fmt.newPrinter(0xed13cae09) 
    /usr/local/Cellar/go/1.6.3/libexec/src/fmt/print.go:133 +0x27 fp=0xc820035e80 sp=0xc820035e40 
fmt.Sprintf(0x1068d8, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0) 
    /usr/local/Cellar/go/1.6.3/libexec/src/fmt/print.go:202 +0x2b fp=0xc820035ed0 sp=0xc820035e80 
log.Printf(0x1068d8, 0x6, 0x0, 0x0, 0x0) 
    /usr/local/Cellar/go/1.6.3/libexec/src/log/log.go:289 +0x49 fp=0xc820035f20 sp=0xc820035ed0 
main.main() 
    /Users/haoy/video_projects/rtc-xswitch2/app/recorder/src/test.go:11 +0x3d fp=0xc820035f50 sp=0xc820035f20 
runtime.main() 
    /usr/local/Cellar/go/1.6.3/libexec/src/runtime/proc.go:188 +0x2b0 fp=0xc820035fa0 sp=0xc820035f50 
runtime.goexit() 
    /usr/local/Cellar/go/1.6.3/libexec/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc820035fa8 sp=0xc820035fa0 
exit status 2 

Répondre