4141 TypeCount uint64 = 0
4242)
4343
44- var (
45- programCache = utils .CreateProgramCache ()
46- )
44+ var programCache = utils .CreateProgramCache ()
4745
4846func encode (vt * rt.GoType , buf unsafe.Pointer , len int , mem thrift.NocopyWriter , p unsafe.Pointer , rs * RuntimeState , st int ) (int , error ) {
4947 if enc , err := resolve (vt ); err != nil {
@@ -65,9 +63,7 @@ func resolve(vt *rt.GoType) (Encoder, error) {
6563 /* record the cache miss, and compile the type */
6664 atomic .AddUint64 (& MissCount , 1 )
6765 val , err = programCache .Compute (vt , compile )
68-
69- /* check for errors */
70- if err != nil {
66+ /* check for errors */ if err != nil {
7167 return nil , err
7268 }
7369
@@ -118,6 +114,15 @@ func EncodeObject(buf []byte, mem thrift.NocopyWriter, val interface{}) (ret int
118114 efv := rt .UnpackEface (val )
119115 out := (* rt .GoSlice )(unsafe .Pointer (& buf ))
120116
117+ if mem == nil {
118+ // starting from go1.22,
119+ // even though `mem`==nil, it may equal to (0x0, 0xc0000fe1e0).
120+ // it keeps original data pointer with itab = nil.
121+ // this would cause JIT panic when we only use data pointer to call its methods.
122+ // updating `mem` to nil, (0x0, 0xc0000fe1e0) -> (0x0, 0x0), is a quick fix for this case.
123+ mem = nil
124+ }
125+
121126 /* check for indirect types */
122127 if efv .Type .IsIndirect () {
123128 ret , err = encode (efv .Type , out .Ptr , out .Len , mem , efv .Value , rst , 0 )
0 commit comments