Commit Graph

5 Commits

Author SHA1 Message Date
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