From 55ea0ea07dc837e596f81ce972361ec46d2cb1fe Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 22 Jun 2017 04:13:36 +0000 Subject: compiler, runtime: better stack trace for `go f()` where f is nil The test for this is TestGoNil in the runtime package, which we don't run yet but will run with a subsequent gotools patch. Updates golang/go#8045 Reviewed-on: https://go-review.googlesource.com/46392 From-SVN: r249494 --- libgo/runtime/go-runtime-error.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libgo/runtime/go-runtime-error.c') diff --git a/libgo/runtime/go-runtime-error.c b/libgo/runtime/go-runtime-error.c index f5ab4f9..4f563fc 100644 --- a/libgo/runtime/go-runtime-error.c +++ b/libgo/runtime/go-runtime-error.c @@ -49,7 +49,10 @@ enum MAKE_CHAN_OUT_OF_BOUNDS = 9, /* Integer division by zero. */ - DIVISION_BY_ZERO = 10 + DIVISION_BY_ZERO = 10, + + /* Go statement with nil function. */ + GO_NIL = 11 }; extern void __go_runtime_error () __attribute__ ((noreturn)); @@ -84,6 +87,12 @@ __go_runtime_error (int32 i) case DIVISION_BY_ZERO: runtime_panicstring ("integer divide by zero"); + case GO_NIL: + /* This one is a throw, rather than a panic. Set throwing to + not dump full stacks. */ + runtime_g()->m->throwing = -1; + runtime_throw ("go of nil func value"); + default: runtime_panicstring ("unknown runtime error"); } -- cgit v1.1