aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-unwind.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-12-12 20:13:58 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-12-12 20:13:58 +0000
commit1635eab367caf9615b4156090fbcd4251fd46e32 (patch)
treecbc29f621fa3a047358c3f193f033b818d994793 /libgo/runtime/go-unwind.c
parent96d91784e5de374f52094e00a1a63dc3f2f157e7 (diff)
downloadgcc-1635eab367caf9615b4156090fbcd4251fd46e32.zip
gcc-1635eab367caf9615b4156090fbcd4251fd46e32.tar.gz
gcc-1635eab367caf9615b4156090fbcd4251fd46e32.tar.bz2
runtime: Fix defer of unlock thread at program startup.
Don't free stack allocated defer block. Also ensure we have a Go context in a few more places before freeing the block. From-SVN: r205940
Diffstat (limited to 'libgo/runtime/go-unwind.c')
-rw-r--r--libgo/runtime/go-unwind.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c
index c669a3c..04b0a28 100644
--- a/libgo/runtime/go-unwind.c
+++ b/libgo/runtime/go-unwind.c
@@ -80,6 +80,7 @@ __go_check_defer (_Bool *frame)
{
struct __go_defer_stack *d;
void (*pfn) (void *);
+ M *m;
d = g->defer;
if (d == NULL || d->__frame != frame || d->__pfn == NULL)
@@ -90,7 +91,9 @@ __go_check_defer (_Bool *frame)
(*pfn) (d->__arg);
- __go_free (d);
+ m = runtime_m ();
+ if (m != NULL && m->mcache != NULL && d->__free)
+ __go_free (d);
if (n->__was_recovered)
{
@@ -119,13 +122,17 @@ __go_check_defer (_Bool *frame)
&& g->defer->__frame == frame)
{
struct __go_defer_stack *d;
+ M *m;
/* This is the defer function which called recover. Simply
return to stop the stack unwind, and let the Go code continue
to execute. */
d = g->defer;
g->defer = d->__next;
- __go_free (d);
+
+ m = runtime_m ();
+ if (m != NULL && m->mcache != NULL && d->__free)
+ __go_free (d);
/* We are returning from this function. */
*frame = 1;