Commit 4044aded authored by David Crawshaw's avatar David Crawshaw

runtime/cgo, cmd/dist: turn off exc_bad_access handler by default

App Store policy requires programs do not reference the exc_server
symbol. (Some public forum threads show that Unity ran into this
several years ago and it is a hard policy rule.) While some research
suggests that I could write my own version of exc_server, the
expedient course is to disable the exception handler by default.

Go programs only need it when running under lldb, which is primarily
used by tests. So enable the exception handler in cmd/dist when we
are running the tests.

Fixes #10646

Change-Id: I853905254894b5367edb8abd381d45585a78ee8b
Reviewed-on: https://go-review.googlesource.com/9549Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 5f69e739
......@@ -94,6 +94,29 @@ func (t *tester) run() {
}
}
if t.iOS() {
// Install the Mach exception handler used to intercept
// EXC_BAD_ACCESS and convert it into a Go panic. This is
// necessary for a Go program running under lldb (the way
// we run tests). It is disabled by default because iOS
// apps are not allowed to access the exc_server symbol.
cmd := exec.Command("go", "install", "-a", "-tags", "lldb", "runtime/cgo")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Fatalf("building mach exception handler: %v", err)
}
defer func() {
cmd := exec.Command("go", "install", "-a", "runtime/cgo")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Fatalf("reverting mach exception handler: %v", err)
}
}()
}
t.timeoutScale = 1
if t.goarch == "arm" || t.goos == "windows" {
t.timeoutScale = 2
......@@ -350,6 +373,10 @@ func (t *tester) dirCmd(dir string, bin string, args ...string) *exec.Cmd {
return cmd
}
func (t *tester) iOS() bool {
return t.goos == "darwin" && (t.goarch == "arm" || t.goarch == "arm64")
}
func (t *tester) out(v string) {
if t.banner == "" {
return
......@@ -417,8 +444,7 @@ func (t *tester) supportedBuildmode(mode string) bool {
func (t *tester) cgoTest() error {
env := mergeEnvLists([]string{"GOTRACEBACK=2"}, os.Environ())
iOS := t.goos == "darwin" && (t.goarch == "arm" || t.goarch == "arm64")
if t.goos == "android" || iOS {
if t.goos == "android" || t.iOS() {
cmd := t.dirCmd("misc/cgo/test", "go", "test")
cmd.Env = env
return cmd.Run()
......
......@@ -15,12 +15,9 @@
// chance to resolve exceptions before the task handler, so we can generate
// the panic and avoid lldb's SIGSEGV handler.
//
// If you want to debug a segfault under lldb, compile the standard library
// with the build tag lldb:
//
// go test -tags lldb -installsuffix lldb
// The dist tool enables this by build flag when testing.
// +build !lldb
// +build lldb
// +build darwin
// +build arm arm64
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !lldb
// +build darwin
// +build arm arm64
// +build lldb
#include <stdint.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment