diff options
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/runtime/malloc.goc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc index 028872259d9..c5e64c893b8 100644 --- a/libgo/runtime/malloc.goc +++ b/libgo/runtime/malloc.goc @@ -84,6 +84,7 @@ runtime_mallocgc(uintptr size, uintptr typ, uint32 flag) MLink *v, *next; byte *tiny; bool incallback; + void *closure; if(size == 0) { // All 0-length allocations use this pointer. @@ -95,6 +96,10 @@ runtime_mallocgc(uintptr size, uintptr typ, uint32 flag) m = runtime_m(); g = runtime_g(); + // We should not be called in between __go_set_closure and the + // actual function call, but cope with it if we are. + closure = g->closure; + incallback = false; if(m->mcache == nil && g->ncgo > 0) { // For gccgo this case can occur when a cgo or SWIG function @@ -175,6 +180,7 @@ runtime_mallocgc(uintptr size, uintptr typ, uint32 flag) m->locks--; if(incallback) runtime_entersyscall(); + g->closure = closure; return v; } } @@ -264,6 +270,8 @@ runtime_mallocgc(uintptr size, uintptr typ, uint32 flag) if(incallback) runtime_entersyscall(); + g->closure = closure; + return v; } |