You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go sometimes panics with a fatal error: checkptr: converted pointer straddles multiple allocations when trying to marshal a certain horrible pointer. (When it doesn't panic, it just hangs forever.)
I'm using Go 1.17.8, just in case that's relevant.
Repro'ing test code is below. Each component of this test seems to be necessary to trigger this bug. Assigning the horrible otherInterface2 to the wrapper's val field causes at least my debugger to lose track of the innermost int type. Perhaps that lost type is somehow to blame for this issue?
import (
"encoding/json""reflect""testing"
gojson "github.com/goccy/go-json""github.com/stretchr/testify/assert"
)
funcTestPointerCrasher(t*testing.T) {
j:=1interfaceJ:=reflect.ValueOf(j).Interface()
interfaceJPtr:=&interfaceJvarotherInterfaceinterface{}
otherInterfacePtr:=&otherInterface*otherInterfacePtr=&interfaceJvarotherInterface2interface{}
otherInterface2Ptr:=&otherInterface2*otherInterface2Ptr=&otherInterfacewrapper:=struct {
valinterface{}
}{val: otherInterface2}
jsonBytes, err:=json.Marshal(wrapper.val)
iferr!=nil {
t.Fatalf("error in json.Marshal: %v", err)
}
// the test will hang in gojson.Marshal()goJsonBytes, err:=gojson.Marshal(wrapper.val)
iferr!=nil {
t.Fatalf("error in gojson.Marshal: %v", err)
}
// this is not generally safe, but we expect these to cast to "1"ifstring(jsonBytes) !=string(goJsonBytes) {
t.Fatalf("expected jsonBytes == goJsonBytes, but %q != %q", jsonBytes, goJsonBytes)
}
}
Go sometimes panics with a
fatal error: checkptr: converted pointer straddles multiple allocations
when trying to marshal a certain horrible pointer. (When it doesn't panic, it just hangs forever.)I'm using Go 1.17.8, just in case that's relevant.
Repro'ing test code is below. Each component of this test seems to be necessary to trigger this bug. Assigning the horrible
otherInterface2
to the wrapper's val field causes at least my debugger to lose track of the innermostint
type. Perhaps that lost type is somehow to blame for this issue?Stack:
The text was updated successfully, but these errors were encountered: