On Mon, Apr 1, 2019 at 7:05 PM Charles <chatha...@logrit.com> wrote: > > We're developing a Go wrapper for a C library/database (YottaDB), and use the > CGO interface to call YottaDB C API functions. We're encountering a variety > of failure symptoms about 1% of the time in our test system; some errors we > get include: > > panic: sync: negative WaitGroup counter > > runtime: unexpected return pc for main.main.func1 called from 0xc42005b100 > > fatal error: unknown caller pc > > runtime: pointer 0x4422f2316c to unallocated span idx=0x1791 > span.base()=0x4422f1e000 span.limit=0x4422f26000 span.state=3 > > fatal error: found bad pointer in Go heap (incorrect use of unsafe or cgo?) > > We've run with cgocheck=2 and the -race option enabled, neither trigger. What > are some other things we can do to debug this issue?
With such a range of errors I would consider memory corruption. Double check your C code to make sure it's not generating any out of range references. You could also try using -fmemory-sanitizer to compile your C code and -msan to compile your Go code. That will catch certain kind of memory errors in your C code. > As an aside, is CGO safe to call from multiple threads/go routines? The > library in question (YottaDB) takes care to properly handle concurrent > threads, so we don't think the issue is there. Yes, it's safe to make concurrent cgo calls from multiple goroutines. 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.