[go-nuts] How can I read bytes from C.Array(three levels) by using Cgo

2016-12-08 Thread Wanghb Wang
my C code Array for example:
const uint8_t** kPacketMaskRandomTbl[48] = {
  kPacketMaskRandom1,
  kPacketMaskRandom2,
  kPacketMaskRandom3,
.
};
const uint8_t* kPacketMaskRandom1[1] = {
  kMaskRandom1_1
};
const uint8_t kMaskRandom1_1[2] = {
  0x80, 0x00
};
.


I want to read bytes from 
kPacketMaskRandomTbl
by using cgo, How can I do?

I write code like this

qq := 
((*uint8)(unsafe.Pointer((uintptr((*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(p))+uintptr(1
 + uintptr((unsafe.Sizeof(*uint8)))

It is not right!
How can I do?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] fatal error:malloc deadlock

2016-09-19 Thread Wanghb Wang
new issue address is https://github.com/golang/go/issues/17165

在 2016年9月20日星期二 UTC+8下午12:04:09,Ian Lance Taylor写道:
>
> On Mon, Sep 19, 2016 at 6:34 PM, Wanghb Wang <wang...@gmail.com 
> > wrote: 
> > 
> > 
> > 在 2016年9月20日星期二 UTC+8上午3:41:09,Ian Lance Taylor写道: 
> >> 
> >> On Mon, Sep 19, 2016 at 8:34 AM, Wanghb Wang <wang...@gmail.com> 
> wrote: 
> >> > 
> >> > when I use stattcpupprof in my program, I got fatal error malloc 
> >> > deadlock. 
> >> > delete the cpu pprof,  the program run well. 
> >> > 
> >> > 
> >> > my question is : 
> >> > Does startcpuprof infect the malloc or resulting OOM Problem 
> >> 
> >> I'm sorry, I don't understand the question. 
> >> 
> >> 
> >> > this is my panic stack trace: 
> >> 
> >> It looks like you have C code that calls goCbStr.  Somehow when that 
> >> happens the malloc lock is held for the thread.  The only way I can 
> >> see that happening is if your C code has a SIGPROF handler that calls 
> >> into Go. 
> >> 
> > 
> > However, I have no  SIGPROF handler(you mean 
> sigaction(SIGPROF,,NULL)?) 
>
> Yes, that kind of thing. 
>
> > my question is: 
> >  why I add startcpupprof  in my golang program (I did have C calls into 
> Go) 
> > result in malloc deadlock? 
>
> I don't know.  Sorry.  If you can tell us precisely how to recreate 
> the problem ourselves--what program to run--please open an issue at 
> https://golang.org/issue.  Thanks. 
>
> Ian 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: fatal error:malloc deadlock

2016-09-19 Thread Wanghb Wang

>
> my dll is compile by visual studio 2015 on windows10
>

If you think this is safe ,  you can rename the attachment test001DLL  as 
test0001.dll, or you can find code from 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


test.go
Description: Binary data


test0001DLL
Description: Binary data


[go-nuts] fatal error:malloc deadlock

2016-09-19 Thread Wanghb Wang
when I use stattcpupprof in my program, I got fatal error malloc deadlock.
delete the cpu pprof,  the program run well.


my question is :
Does startcpuprof infect the malloc or resulting OOM Problem
this is my panic stack trace:


fatal error: malloc deadlock
goroutine 17 [running, locked to thread]:
runtime.throw(0x845aa0, 0xf)
C:/Go/src/runtime/panic.go:547 +0x97 fp=0xc082025c68 sp=0xc082025c50
runtime.mallocgc(0x5, 0x0, 0x3, 0x822aa0)
C:/Go/src/runtime/malloc.go:544 +0x1e1 fp=0xc082025d40 
sp=0xc082025c68
runtime.rawstring(0x5, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Go/src/runtime/string.go:284 +0x77 fp=0xc082025d88 
sp=0xc082025d40
runtime.gostring(0x7ff94f7f992c, 0x0, 0x0)
C:/Go/src/runtime/string.go:341 +0x62 fp=0xc082025df0 
sp=0xc082025d88
main._Cfunc_GoString(0x7ff94f7f992c, 0x0, 0x0)
test/_obj/_cgo_gotypes.go:44 +0x34 fp=0xc082025e10 sp=0xc082025df0
main.goCbStr(0x1, 0x2, 0x7ff94f7f992c, 0xa20fd0)
C:/Programming/go-src/src/test/test.go:125 +0x62 fp=0xc082025ed0 
sp=0xc082025e10
runtime.call32(0x0, 0x8eb238, 0x3befdd0, 0x20)
C:/Go/src/runtime/asm_amd64.s:472 +0x45 fp=0xc082025ef8 
sp=0xc082025ed0
runtime.cgocallbackg1()
C:/Go/src/runtime/cgocall.go:267 +0x11a fp=0xc082025f30 
sp=0xc082025ef8
runtime.cgocallbackg()
C:/Go/src/runtime/cgocall.go:180 +0xde fp=0xc082025f90 
sp=0xc082025f30
runtime.cgocallback_gofunc(0x0, 0x0, 0x0)
C:/Go/src/runtime/asm_amd64.s:716 +0x6d fp=0xc082025fa0 
sp=0xc082025f90
runtime.goexit()
C:/Go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc082025fa8 
sp=0xc082025fa0

goroutine 1 [sleep]:
time.Sleep(0x3b9aca00)
C:/Go/src/runtime/time.go:59 +0x107
main.main()
C:/Programming/go-src/src/test/test.go:64 +0x4c3

goroutine 18 [syscall, locked to thread]:
runtime.goexit()
C:/Go/src/runtime/asm_amd64.s:1998 +0x1

goroutine 6 [syscall]:
runtime.CPUProfile(0x0, 0x0, 0x0)
C:/Go/src/runtime/cpuprof.go:421 +0x3b
runtime/pprof.profileWriter(0x1742f0, 0xc082026038)
C:/Go/src/runtime/pprof/pprof.go:607 +0x23
created by runtime/pprof.StartCPUProfile
C:/Go/src/runtime/pprof/pprof.go:601 +0x14c

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: C.dll callback golang func will stuck

2016-09-09 Thread Wanghb Wang


在 2016年9月10日星期六 UTC+8上午5:01:14,James Bardin写道:
>
> You have a busy loop in main. Use another method to block, like a read in 
> stdin, wait for a signal, etc. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.