[go-nuts] Re: cgo, CString and C.free

2016-09-02 Thread Elias Naur
Hi, Test() never actually dereference the C string (now dangling) pointer after C.free. And even if it did, it is unlikely that the C.free() resulted in the memory page your string resided on was unmapped. Segfaults only happen if you access unmapped memory. - elias On Friday, September 2, 2

[go-nuts] Re: cgo, CString and C.free

2016-09-02 Thread Kane Kim
Nevermind, looks like it is undefined behavior here. On Friday, September 2, 2016 at 1:43:49 AM UTC-7, kane@sendgrid.com wrote: > > Hello, > > I was expecting it to segfault after deallocating CString. How does it > work internally? > > func (m *Message) Test() string { > s := C.CString("tes