diff options
Diffstat (limited to 'libgo/runtime/go-panic.c')
-rw-r--r-- | libgo/runtime/go-panic.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libgo/runtime/go-panic.c b/libgo/runtime/go-panic.c index 530629c..7e284ee 100644 --- a/libgo/runtime/go-panic.c +++ b/libgo/runtime/go-panic.c @@ -54,6 +54,7 @@ __go_panic (struct __go_empty_interface arg) { struct __go_defer_stack *d; void (*pfn) (void *); + M *m; d = g->defer; if (d == NULL) @@ -95,7 +96,14 @@ __go_panic (struct __go_empty_interface arg) } g->defer = d->__next; - __go_free (d); + + /* This may be called by a cgo callback routine to defer the + call to syscall.CgocallBackDone, in which case we will not + have a memory context. Don't try to free anything in that + case--the GC will release it later. */ + m = runtime_m (); + if (m != NULL && m->mcache != NULL) + __go_free (d); } /* The panic was not recovered. */ |