Skip to content

Commit

Permalink
Change type of zed.nativeBase for Go 1.21
Browse files Browse the repository at this point in the history
Unlike previous releases, Go 1.21 assigns zed.nativeBase (a struct{}
occupying zero bytes) the same address as runtime.zerobase, causing
panics because zed.decodeNative now mistakes a zed.Value with a bytes
field containing a zero-capacity slice for a native value.  Fix by
changing the type of nativeBase to uintptr, which does not occupy zero
bytes.

Closes #4764.
  • Loading branch information
nwt committed Sep 25, 2023
1 parent b1af18c commit a2dbdec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (v *Value) Bytes() zcode.Bytes {
// nativeBase is the base address for all native Values, which are encoded as a
// zcode.Bytes with this base address, a length of zero, and capacity set to the
// bits of the value's native representation.
var nativeBase struct{}
var nativeBase uintptr

func encodeNative(x uint64) zcode.Bytes {
var b zcode.Bytes
Expand Down

0 comments on commit a2dbdec

Please sign in to comment.