go1.14.4 / darwin / amd64

I'm tracking down an issue where a certain code (not sure where, in large 
legacy code) 
is touching memory that it should not.

I thought of the old electric fence technique from C. The electric fence 
memory allocator would put each object
on its own page on malloc(). Then on free(), it would mark the page as 
invalid, so that the next time
user code tried to read from the memory that had already been freed, an 
immediate segfault
would give us a stack trace and tell those of us debugging exactly where 
the bad access had
come from.

I'd like to do the same in Go.

GODEBUG=efence=1

says, quoting from https://golang.org/pkg/runtime/

efence: setting efence=1 causes the allocator to run in a mode
where each object is allocated on a unique page and addresses are
never recycled.


so the first part is already available in Go. Now I just need your 
assistance figuring out the 2nd part.

How can go code take the pointer address of an object, and mark that page 
as "invalid" so that
any read of it will segfault?

Thanks!

-- 
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/e09615c7-2b6a-478e-b0e6-45ba204c0073o%40googlegroups.com.

Reply via email to