-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.20.4 darwin/arm64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/r/Library/Caches/go-build" GOENV="/Users/r/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOMODCACHE="/Users/r/go/pkg/mod" GOOS="darwin" GOPATH="/Users/r/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/Users/r/sdk/go1.20.4" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/r/sdk/go1.20.4/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.20.4" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j_/rq9ph2cd3h50w468sgv34lwh0000gn/T/go-build3924141508=/tmp/go-build -gno-record-gcc-switches -fno-common" GOROOT/bin/go version: go version go1.20.4 darwin/arm64 GOROOT/bin/go tool compile -V: compile version go1.20.4 uname -v: Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 ProductName: macOS ProductVersion: 13.3.1 ProductVersionExtra: (a) BuildVersion: 22E772610a lldb --version: lldb-1403.0.17.64 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
What did you do?
test.go:
package main
import (
"arena"
"fmt"
"reflect"
)
func main() {
a := arena.NewArena()
i := 0
v := reflect.ArenaNew(a, reflect.TypeOf(i))
fmt.Println(v.Type(), *v.Interface().(*int))
a.Free()
}
GOEXPERIMENT=arenas go1.20.4 run -a test.go
What did you expect to see?
*int 0
What did you see instead?
panic:
fatal error: arena_New: non-pointer type
goroutine 1 [running]:
runtime.throw({0x1025c532b?, 0x10254070c?})
/Users/r/sdk/go1.20.4/src/runtime/panic.go:1047 +0x40 fp=0x140000a4e20 sp=0x140000a4df0 pc=0x102564dd0
arena.runtime_arena_arena_New(0x129cc1408?, {0x1025fa760, 0x1025eb8a0})
/Users/r/sdk/go1.20.4/src/runtime/arena.go:113 +0x78 fp=0x140000a4e60 sp=0x140000a4e20 pc=0x10258d318
reflect.arena_New(0x140000a4ec8?, {0x1025fa760?, 0x1025eb8a0?})
/Users/r/sdk/go1.20.4/src/arena/arena.go:89 +0x28 fp=0x140000a4e90 sp=0x140000a4e60 pc=0x1025952d8
reflect.ArenaNew(0x1025f06e0?, {0x1025ff038?, 0x1025eb8a0?})
/Users/r/sdk/go1.20.4/src/reflect/arena.go:15 +0x2c fp=0x140000a4ed0 sp=0x140000a4e90 pc=0x1025a39fc
main.main()
/Users/r/workspace/testcode/testarena/test.go:12 +0xa0 fp=0x140000a4f70 sp=0x140000a4ed0 pc=0x1025c1050
runtime.main()
/Users/r/sdk/go1.20.4/src/runtime/proc.go:250 +0x248 fp=0x140000a4fd0 sp=0x140000a4f70 pc=0x1025673f8
runtime.goexit()
/Users/r/sdk/go1.20.4/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000a4fd0 sp=0x140000a4fd0 pc=0x102592364
If I change the code to v := reflect.ArenaNew(a, reflect.TypeOf(&i))
, it will pass.
But it conflicts with the comment of reflect.ArenaNew:
// ArenaNew returns a Value representing a pointer to a new zero value for the
// specified type, allocating storage for it in the provided arena. That is,
// the returned Value's Type is PointerTo(typ).
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.