Commit Graph

8 Commits

Author SHA1 Message Date
Ian Lance Taylor a1f25eafec handles, merge: simplify code, don't copy file contents 2016-02-16 21:34:43 -08:00
Ian Lance Taylor 42b11d403d handles, merge, odb: changes for Go 1.6 pointer passing rules
See http://tip.golang.org/cmd/cgo/#hdr-Passing_pointers .
2016-01-07 18:37:46 -08:00
Dmitri Shuralyov e1e1b4b1e1 Prevent slot int variable from being GCed.
Before this change, there were no users of slot int variable in the Go
world (just a pointer to it that ended up in C world only), so Go's
garbage collector would free it and its value could not retrieved later
(once a pointer to it comes back to Go world from C world).

Keep a pointer to it in the Go world so that does not happen.

Fixes #218.
2015-07-26 15:02:40 -07:00
Patrick Steinhardt 1bd338af5e handles: do not store handles by uintptr
If we store values by uintptrs the GC may try to inspect their
values when it kicks in. As the pointers are most likely invalid,
this will result in an invalid pointer dereference, causing the
program to panic. We can fix this by storing values by an int
index value instead, returning pointers to those indices as
handles instead.
2015-05-22 09:50:16 +02:00
Patrick Steinhardt 7ee534d0c5 handles: print pointer handle on panic. 2015-05-22 09:02:24 +02:00
Patrick Steinhardt 0a336e4abd handles: start slot indices with 1
Using 0 as the first slot indice leads to not being able to
differentiate between a handle to the first element or a
NULL-handle. As current code may check whether the pointer is
NULL, change the first indice to be 1 instead.
2015-05-22 09:02:24 +02:00
Patrick Steinhardt bde012f3d4 handles: correctly initialize all members 2015-05-22 09:02:24 +02:00
Carlos Martín Nieto 7750e85fd1 Introduce an indirection layer for pointers
As the Go runtime can move stacks at any point and the C code runs
concurrently with the rest of the system, we cannot assume that the
payloads we give to the C code will stay valid for any particular
duration.

We must therefore give the C code handles which we can then look up in
our own list when the callbacks get called.
2015-05-22 09:02:24 +02:00