mirror of
https://github.com/golang/go.git
synced 2025-05-30 19:52:53 +00:00
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>
This commit is contained in:
parent
166cfd2c87
commit
dd6753a6f2
@ -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) {
|
func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) {
|
||||||
if cgoInRange(p, mheap_.arena_start, mheap_.arena_used) {
|
if cgoInRange(p, mheap_.arena_start, mheap_.arena_used) {
|
||||||
if !inheap(uintptr(p)) {
|
if !inheap(uintptr(p)) {
|
||||||
// This pointer is either to a stack or to an
|
// On 32-bit systems it is possible for C's allocated memory
|
||||||
// unused span. Escape analysis should
|
// to have addresses between arena_start and arena_used.
|
||||||
// prevent the former and the latter should
|
// Either this pointer is a stack or an unused span or it's
|
||||||
// not happen.
|
// a C allocation. Escape analysis should prevent the first,
|
||||||
panic(errorString("cgo argument has invalid Go pointer"))
|
// garbage collection should prevent the second,
|
||||||
|
// and the third is completely OK.
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
b, hbits, span := heapBitsForObject(uintptr(p), 0, 0)
|
b, hbits, span := heapBitsForObject(uintptr(p), 0, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user