diff options
author | Elias Naur <elias.naur@gmail.com> | 2015-07-11 12:59:00 +0200 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2015-07-11 11:39:05 +0000 |
commit | b3a8b0574ad94c0b26cacb2e926848f18ecb29f3 (patch) | |
tree | 48a05b7015d541aeacf8ca36894cff4490b22b63 /src/runtime/runtime1.go | |
parent | d5004ee69e117936890bf85b924c38f3bb505a6d (diff) | |
download | go-b3a8b0574ad94c0b26cacb2e926848f18ecb29f3.tar.gz go-b3a8b0574ad94c0b26cacb2e926848f18ecb29f3.zip |
runtime: abort on fatal errors and panics in c-shared and c-archive modes
The default behaviour for fatal errors and runtime panics is to dump
the goroutine stack traces and exit with code 2. However, when the process is
owned by foreign code, it is suprising and inappropriate to suddenly exit
the whole process, even on fatal errors. Instead, re-use the crash behaviour
from GOTRACEBACK=crash and abort.
The motivating use case is issue #11382, where an Android crash reporter
is confused by an exiting process, but I believe the aborting behaviour
is appropriate for all cases where Go does not own the process.
The change is simple and contained and will enable reliable crash reporting
for Android apps in Go 1.5, but I'll leave it to others to judge whether it
is too late for Go 1.5.
Fixes #11382
Change-Id: I477328e1092f483591c99da1fbb8bc4411911785
Reviewed-on: https://go-review.googlesource.com/12032
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/runtime1.go')
-rw-r--r-- | src/runtime/runtime1.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/runtime/runtime1.go b/src/runtime/runtime1.go index e483178d64..db26995703 100644 --- a/src/runtime/runtime1.go +++ b/src/runtime/runtime1.go @@ -376,6 +376,11 @@ func parsedebugvars() { default: traceback_cache = uint32(atoi(p)) << 1 } + // when C owns the process, simply exit'ing the process on fatal errors + // and panics is surprising. Be louder and abort instead. + if islibrary || isarchive { + traceback_cache |= 1 + } } // Poor mans 64-bit division. |