On Fri, Jul 12, 2019 at 10:53 AM Nitish Saboo <nitish.sabo...@gmail.com>
wrote:

> Thanks for pointing it out.I am a beginner with Go and  CGO and have never
> worked on corruption issues with C.
> I am familiar with python and Java.So just seeking help from the experts
> to find the pain points that should be looked into.
> Hence, asking questions to Ian as in where all I should look for the
> corruption issues.
>

Nitish, I would start by taking the error message at face value. That is,
assume you're freeing a dynamically allocated buffer more than once. Then
review your code with that assumption in mind to see how that might occur.

There are also tools that are invaluable when debugging this type of issue.
Starting with code linters such as cppcheck, oclint, and enabling all
warnings your compiler supports and paying attention to them. Next, take
advantage of your platform debug malloc library which is enabled by setting
environment variables such as "MallocGuardEdges" (the actual env vars is
specific to your platform so "man 3 malloc"). There are more sophisticated
tool such as Valgrind and ASAN (address sanitizer). ASAN is an incredibly
helpful tool for this type of issue and I always use it if possible for
debugging memory management bugs in C/C++ code. Unfortunately I don't know
how to enable its use with cgo or even if it is possible.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD8fkxEq1zZ18HgxZDmWi3TX8HOcsgZJvvKZHSp3WW5gqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to