Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x7fe3502cca80 pc=0x7fe34d9320b4] #30901

Closed
grjiq opened this issue Mar 18, 2019 · 5 comments

Comments

@grjiq
Copy link

grjiq commented Mar 18, 2019

What version of Go are you using (go version)?

$ go version
go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/data1/mickeytang/go_env/go_pkg/"
GORACE=""
GOROOT="/data1/mickeytang/go_env/go"
GOTMPDIR=""
GOTOOLDIR="/data1/mickeytang/go_env/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build151147840=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I'm using cgo copy a go-memory to c-mempory. Here is my code.
data_shmaddr, _, _ := syscall.Syscall(syscall.SYS_SHMAT, mp_mgr.data_key, 0, 0) C.memcpy(unsafe.Pointer(data_shmaddr+uintptr(per_offs)), unsafe.Pointer((C.CString)(string(*data))), C.ulong(len(*data)))

What did you expect to see?

I expect that the function 'C.memcpy' works successfully.

What did you see instead?

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7fe3502cca80 pc=0x7fe34d9320b4]

runtime stack:
runtime.throw(0x552be5, 0x2a)
/data1/user1/go_env/go/src/runtime/panic.go:619 +0x81
runtime.sigpanic()
/data1/user1/go_env/go/src/runtime/signal_unix.go:372 +0x28e

goroutine 1 [syscall]:
runtime.cgocall(0x4fe960, 0xc4200edd40, 0x29)
/data1/user1/go_env/go/src/runtime/cgocall.go:128 +0x64 fp=0xc4200edd00 sp=0xc4200edcc8 pc=0x403034
main._Cfunc_memcpy(0x7fe3502cca80, 0x7fe3440008c0, 0x1, 0x0)
_cgo_gotypes.go:78 +0x4e fp=0xc4200edd40 sp=0xc4200edd00 pc=0x4fdb7e
main.(*MemPoolMng).PutData.func1(0x7fe3502cca80, 0x7fe3440008c0, 0x1, 0x1)
/data1/user2/GoServer/mempool_go/mempool_mgr.go:107 +0x99 fp=0xc4200edd78 sp=0xc4200edd40 pc=0x4fe7a9
main.(*MemPoolMng).PutData(0xc4200182d0, 0xc420158000, 0xf4240)
/data1/user2/GoServer/mempool_go/mempool_mgr.go:107 +0x1da fp=0xc4200ede58 sp=0xc4200edd78 pc=0x4fe37a
main.handleProtoClient(0x565720, 0xc42000e060)
/data1/user2/GoServer/mempool_go/server.go:58 +0x16f fp=0xc4200eded0 sp=0xc4200ede58 pc=0x4fcf8f
main.main()
/data1/user2/GoServer/mempool_go/server.go:39 +0x261 fp=0xc4200edf88 sp=0xc4200eded0 pc=0x4fcca1
runtime.main()
/data1/user1/go_env/go/src/runtime/proc.go:198 +0x212 fp=0xc4200edfe0 sp=0xc4200edf88 pc=0x42b772
runtime.goexit()
/data1/user1/go_env/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200edfe8 sp=0xc4200edfe0 pc=0x455601
exit status 2

@grjiq
Copy link
Author

grjiq commented Mar 18, 2019

Sometimes this error appears, while sometimes not.

@randall77
Copy link
Contributor

It is segfaulting on the destination address from the memcpy. That means that address isn't mapped. I don't think this bug has anything to do with Go proper. In particular you should check the error return of syscall.Syscall, and investigate whether per_offs is correct.

Without a more complete program there's no way for us to investigate further.

@grjiq
Copy link
Author

grjiq commented Mar 18, 2019

data_id, _, err3 := syscall.Syscall(syscall.SYS_SHMGET, uintptr(10001), 1<<32, IpcCreate|0600) data_shmaddr, _, _ := syscall.Syscall(syscall.SYS_SHMAT,data_id ,0, 0) C.memcpy_c((*C.char)(unsafe.Pointer(data_shmaddr)), per_offs, (C.CString)(string(*data)), 0, C.int(len(*data)))
per_offs is an int value far less than 1<<32, as you say, not all the address is mapped. so how can i map the address form data_shmaddr to (data_shmaddr+1<<32)? I would appreciate your help.@randall77

@randall77
Copy link
Contributor

I don't know. I've never used shmget/shmat.
I suggest that you ask on the golang-nuts Google Group or in some other forum; see https://golang.org/wiki/Questions.

@grjiq
Copy link
Author

grjiq commented Mar 18, 2019

thank you anyway.

@golang golang locked and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants