Skip to content

MariappanBalraj/test_cgo_panic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Steps to build and get the core dump. CGO_CFLAGS="-g" go build -gcflags=all="-N -l" . ulimit -c unlimited echo "core" > /proc/sys/kernel/core_pattern export GOTRACEBACK=crash

test_cgo_panic-main# /root/go/bin/dlv core ./test core.1106319

(dlv) bt
 0  0x0000000000460ec1 in runtime.raise
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/sys_linux_amd64.s:154
 1  0x0000000000449865 in runtime.dieFromSignal
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/signal_unix.go:879
 2  0x0000000000449e45 in runtime.sigfwdgo
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/signal_unix.go:1092
 3  0x00000000004487c7 in runtime.sigtrampgo
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/signal_unix.go:432
 4  0x0000000000461186 in runtime.sigtramp
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/sys_linux_amd64.s:352
 5  0x0000153219292520 in ???
    at ?:-1
 6  0x0000000000449a78 in runtime.crash
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/signal_unix.go:971
 7  0x0000000000434da5 in runtime.fatalpanic
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/panic.go:1168
 8  0x00000000004344ec in runtime.gopanic
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/panic.go:987
 9  0x00000000004642a7 in main.Test4
    at ./export.go:8
10  0x000000000046431c in _cgoexp_209e16473f08_Test4
    at _cgo_gotypes.go:61
11  0x000000000040535b in runtime.cgocallbackg1
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/cgocall.go:315
12  0x0000000000405079 in runtime.cgocallbackg
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/cgocall.go:234
13  0x0000000000461b0f in runtime.cgocallbackg
    at <autogenerated>:1
14  0x000000000045f3f4 in runtime.cgocallback
    at /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/asm_amd64.s:998
15  0x0000000000000001 in ???
15  0x0000000000000001 in ???
    at ?:-1
16  0x000000c00003e000 in ???
    at ?:-1
    error: error while reading spliced memory at 0x8: EOF
(truncated)

Line which is causing the issue is clear from the following runtime debugging using dlv.

  test_cgo_panic-main# /root/go/bin/dlv exec ./test
(dlv) break runtime.unwindm
Breakpoint 1 set at 0x4054e6 for runtime.unwindm() /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/cgocall.go:326
(dlv) c
> runtime.unwindm() /home/soomohan/mbalraj/GO/go1.20.2/go/src/runtime/cgocall.go:326 (hits goroutine(1):1 total:1) (PC: 0x4054e6)
Warning: debugging optimized function
   321:         // Do not unwind m->g0->sched.sp.
   322:         // Our caller, cgocallback, will do that.
   323:         restore = false
   324: }
   325:
=> 326: func unwindm(restore *bool) {
   327:         if *restore {
   328:                 // Restore sp saved by cgocallback during
   329:                 // unwind of g's stack (see comment at top of file).
   330:                 mp := acquirem()
   331:                 sched := &mp.g0.sched
(dlv) n
(dlv) n
(dlv) n
(dlv) p %x mp.g0.sched.sp
7ffcc23bda48
(dlv) n
(dlv) p %x mp.g0.sched.sp
7ffcc23bdbb8

Go environment

root@soomohan:/home/soomohan/mbalraj/test_hb2# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/soomohan/mbalraj/GO/go1.20.2/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/soomohan/mbalraj/GO/go1.20.2/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.2"
GCCGO="/usr/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3821222181=/tmp/go-build -gno-record-gcc"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages