-3

I'm in a bit of a mess, and I cannot see how I'm getting out of it... What do I got: * A library (dll) I built using cgo. * A c++ app using this library (dll).

What do I do: I try to free memory I have allocated in the cgo library in the c++ app.

What Tools do I use: To build the library (dll) I use cgo, then creating a stub lib using the VS cmd. I use visual studio 2017 to compile the app (with /MD) option.

What do I get: Critical error detected c0000374

As far as I can see, this is a result of me freeing data which was allocated in the dll libarary. I will note that this does not happen if I create a test app and compile it with gcc.

Unfortunately, I can not avoid using VS as I am working with some CUDA stuff which like VS better :/

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Liron Levy
  • 41
  • 1
  • 7
  • 1
    _why_ are you trying to free Go memory from the C++ app at all? You can't free memory that the Go runtime is managing. – JimB May 24 '18 at 15:25
  • It is a bit if a mess... But I'm actually freeing c memory allocated in go, or in more details: i have a callback function which receive its variables from go, but as some of these are strings they have been converted to c strings which move them to c memory (this is how cgo works). Due to callbacks and the fact that I do not want to send a copy as it will be a hugh waste , this is what happened :/ – Liron Levy May 24 '18 at 19:00

1 Answers1

0

After much searching, there is no way to create one heap when using go,cgo and Visual Studio. To solve this I add a free function which free the cgo memory in the cgo library.

Liron Levy
  • 41
  • 1
  • 7