Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go GOTRACEBACK=crash with no core file

go version go1.8.3 darwin/amd64

ulimit -c unlimited
env GOTRACEBACK=crash ./testgotraceback.go
ls -al 
no core file generated.

testgotraceback.go source file

package main

import (
    "fmt"
    "time"
)

func saferoutine(c chan bool) {
    for i := 0; i < 10; i++ {
        fmt.Println("Count:", i)
        time.Sleep(1 * time.Second)
    }
    c <- true
}
func panicgoroutine(c chan bool) {
    time.Sleep(5 * time.Second)
    panic("Panic, omg ...")
    c <- true
}
func main() {
    c := make(chan bool, 2)
    go saferoutine(c)
    go panicgoroutine(c)
    for i := 0; i < 2; i++ {
        <-c
    }
}

I want to use core file to trace some error.But use the GOTRACEBACK=crash command,I find no core file.use golang1.7 as well. so ,what's the problem?thanks for help.

like image 707
lindsay show Avatar asked Dec 11 '25 04:12

lindsay show


1 Answers

If you are expecting a core dump file to be created in the directory where you program is being run, you not only need to use ulimit and set GOTRACEBACK but also change settings on your operating system to save core file in the current directory.

Assuming you are using Linux, this is distribution-specific. You need to find relevant sysfs entry and save core value to it. For example, a core pattern sysfs entry on Fedora is /proc/sys/kernel/core_pattern and to setup you OS to save core files in the current directory, you would need to execute:

echo core > /proc/sys/kernel/core_pattern
like image 98
syntagma Avatar answered Dec 14 '25 01:12

syntagma