aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/runtime/cgo/gcc_linux_amd64.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/cgo/gcc_linux_amd64.c b/src/runtime/cgo/gcc_linux_amd64.c
index c25e7e769b..fb164c1a1d 100644
--- a/src/runtime/cgo/gcc_linux_amd64.c
+++ b/src/runtime/cgo/gcc_linux_amd64.c
@@ -44,7 +44,9 @@ x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
}
pthread_attr_init(attr);
pthread_attr_getstacksize(attr, &size);
- g->stacklo = (uintptr)&size - size + 4096;
+ g->stacklo = (uintptr)__builtin_frame_address(0) - size + 4096;
+ if (g->stacklo >= g->stackhi)
+ fatalf("bad stack bounds: lo=%p hi=%p\n", g->stacklo, g->stackhi);
pthread_attr_destroy(attr);
free(attr);