Re: [go-nuts] Signal SIGSEGV: segmentation violation code=0x1

2019-03-21 Thread Ian Lance Taylor
The first step is certainly to consistently check the error returns of all your system calls. Right now you are ignoring the error returns of your SHMAT calls. Ian On Thu, Mar 21, 2019 at 8:24 AM <615912...@qq.com> wrote: > > Here is my code. > package main > > /* > #include > #include > #incl

Re: [go-nuts] Signal SIGSEGV: segmentation violation code=0x1

2019-03-21 Thread 615912558
Here is my code. package main /* #include #include #include static void memcpy_c(char *dest, int offs1, char *src, int offs2, int cnt) { if (src == 0 || dest == 0) { printf("a null ptr.\n"); return; } int a = 0; long i = 0; memcpy(dest + offs1, src+offs2, cnt); while (1){ if (i >= cnt) { break;

Re: [go-nuts] Signal SIGSEGV: segmentation violation code=0x1

2019-03-18 Thread Ian Lance Taylor
On Mon, Mar 18, 2019 at 8:17 PM <615912...@qq.com> wrote: > > shmid, _, err := syscall.Syscall(syscall.SYS_SHMGET, uintptr(10001), 1<<32, > IpcCreate|0600) > data_shmaddr, _, _ := syscall.Syscall(syscall.SYS_SHMAT, shmid, 0, 0) > C.memcpy(unsafe.Pointer(data_shmaddr+uintptr(per_offs)), > unsafe.P

[go-nuts] Signal SIGSEGV: segmentation violation code=0x1

2019-03-18 Thread 615912558
shmid, _, err := syscall.Syscall(syscall.SYS_SHMGET, uintptr(10001), 1<<32, IpcCreate|0600) data_shmaddr, _, _ := syscall.Syscall(syscall.SYS_SHMAT, shmid, 0, 0) C.memcpy(unsafe.Pointer(data_shmaddr+uintptr(per_offs)), unsafe.Pointer((C. CString)(string(*data))), C.ulong(len(*data))) I'm trying t