diff options
author | Russ Cox <rsc@golang.org> | 2016-01-13 12:23:44 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2016-01-13 19:06:28 +0000 |
commit | dd6753a6f28ade7b7d24d082b438de3c7dd48557 (patch) | |
tree | 01a6d97dabd6c53ff88556546c024854990712c1 | |
parent | 166cfd2c878a806897526ba7bfecda060323cba5 (diff) | |
download | go-dd6753a6f28ade7b7d24d082b438de3c7dd48557.tar.gz go-dd6753a6f28ade7b7d24d082b438de3c7dd48557.zip |
runtime: allow for C pointers between arena_start and arena_used in cgo check
Fixes #13928.
Change-Id: Ia04c6bdef5ae6924d03982682ee195048f8f387f
Reviewed-on: https://go-review.googlesource.com/18611
Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/runtime/cgocall.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go index 3b395fb8cd..210d1862f9 100644 --- a/src/runtime/cgocall.go +++ b/src/runtime/cgocall.go @@ -502,11 +502,13 @@ func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) { func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) { if cgoInRange(p, mheap_.arena_start, mheap_.arena_used) { if !inheap(uintptr(p)) { - // This pointer is either to a stack or to an - // unused span. Escape analysis should - // prevent the former and the latter should - // not happen. - panic(errorString("cgo argument has invalid Go pointer")) + // On 32-bit systems it is possible for C's allocated memory + // to have addresses between arena_start and arena_used. + // Either this pointer is a stack or an unused span or it's + // a C allocation. Escape analysis should prevent the first, + // garbage collection should prevent the second, + // and the third is completely OK. + return } b, hbits, span := heapBitsForObject(uintptr(p), 0, 0) |