You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]
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.
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
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.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat 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
The text was updated successfully, but these errors were encountered: