GithubHelp home page GithubHelp logo

go's Issues

panic when marshal struct

The code below will panic:

package main

import (
	"fmt"

	"github.com/thrift-iterator/go"
)

type Foo struct {
	Sa string   `thrift:"Sa,1" json:"Sa"`
	Ib int32    `thrift:"Ib,2" json:"Ib"`
	Lc []string `thrift:"Lc,3" json:"Lc"`
}

type Example struct {
	Name string          `thrift:"Name,1" json:"Name"`
	Ia   int64           `thrift:"Ia,2" json:"Ia"`
	Lb   []string        `thrift:"Lb,3" json:"Lb"`
	Mc   map[string]*Foo `thrift:"Mc,4" json:"Mc"`
}

func main() {

	var example = Example{
		Name: "xxxxxxxxxxxxxxxx",
		Ia:   12345678,
		Lb:   []string{"a", "b", "c", "d", "1", "2", "3", "4", "5"},
		Mc: map[string]*Foo{
			"t1": &Foo{Sa: "sss", Ib: 987654321, Lc: []string{"1", "2", "3"}},
		},
	}

	fmt.Printf("example: %v\n", example)
	_, err := thrifter.Marshal(example)

	if err != nil {
		fmt.Printf("err: %v\n", err)
	}
}

the panic msg is below:

example: {xxxxxxxxxxxxxxxx 12345678 [a b c d 1 2 3 4 5] map[t1:0xc000132450]}
panic: runtime error: growslice: cap out of range
goroutine 1 [running]:
github.com/thrift-iterator/go/protocol/binary.(*Stream).WriteString(0xc000148000, 0xbcce73b5c2737373, 0x203d2120bdbfef73)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/protocol/binary/stream.go:164 +0x116
github.com/thrift-iterator/go/binding/reflection.(*stringEncoder).encode(0xa79998, 0x6cceed, 0x6ff940, 0xc000148000)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/binding/reflection/encode_simple_value.go:24 +0x4a
github.com/thrift-iterator/go/binding/reflection.(*structEncoder).encode(0xc00000d180, 0x6cceed, 0x6ff940, 0xc000148000)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/binding/reflection/encode_struct.go:35 +0x156
github.com/thrift-iterator/go/binding/reflection.(*pointerEncoder).encode(0xc00000d1a0, 0xc000132450, 0x6ff940, 0xc000148000)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/binding/reflection/encode_pointer.go:20 +0x87
github.com/thrift-iterator/go/binding/reflection.(*mapEncoder).encode(0xc000132510, 0xc000132420, 0x6ff940, 0xc000148000)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/binding/reflection/encode_map.go:30 +0x2da
github.com/thrift-iterator/go/binding/reflection.(*structEncoder).encode(0xc00000d1c0, 0xc0000bcc00, 0x6ff940, 0xc000148000)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/binding/reflection/encode_struct.go:35 +0x156
github.com/thrift-iterator/go/binding/reflection.(*valEncoderAdapter).Encode(0xc0000107a0, 0x6aed20, 0xc0000bcc00, 0x6ff940, 0xc000148000)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/binding/reflection/unsafe.go:45 +0x51
github.com/thrift-iterator/go.(*frozenConfig).Marshal(0xc000136000, 0x6aed20, 0xc0000bcc00, 0x6aed20, 0xc0000bcc00, 0xc0000a9f18, 0xc0000bcc00, 0xc0000bcc00)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/config.go:251 +0x175
github.com/thrift-iterator/go.Marshal(0x6aed20, 0xc0000bcc00, 0x6aed20, 0xc0000bcc00, 0x1, 0x4e, 0x0)
/data01/xuhuaye/go/src/github.com/thrift-iterator/go/api.go:72 +0x49
main.main()
/data01/xuhuaye/go/src/iven_learn/test_thrifter/test.go:34 +0x317
exit status 2

序列化失败,并且会出现乱码数据

body, _ := hex.DecodeString("8241010473796e630c001c19fc6016ec1016ea839185cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373136363739373839323937303132353316e2839185cd6216008215003b01880b6532656556657273696f6e0132130019581013758b21c122218d59355273fe6b9d871ea4b55ebf69f1291184a064a47805c71d9b609d4f9512b178bf3cc8bc8f210c000000000000000b04a53811040043a290040043a9a1790c000016ee1016b2acd096cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373136393837353537303933303530333116aaacd096cd6216008215003b01880b6532656556657273696f6e013213001958106aa1272be67a8cd8d413c09eef52f7881c1db50db0e9834ec02526f5d03c894c3ab99bdc0e894cf61d17d41af20c000000000000000c2467620b040043a290040043a9a1790c000016f01016dee49b97cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373136393937393238393333313331363916d6e49b97cd6216008215003b01880b6532656556657273696f6e013213001958101917bdad299302a1948fb09bd2fd30221c39016abf3145784833878ac34509166a24b8944acd115150abd66ef10c000000000000000d228d96fa040043a290040043a9a1790c000016f21016a6a69d97cd62155015d68c01682175353163386666323362343539346663623166336630313337383033666233336318123437313639383735353730393330353033311801300016f41016f8f99e97cd621532152e680130ac182175393536343963623937663839316464663663626336616265653334636165393718217535316338666632336234353934666362316633663031333738303366623333631500181234373136393938333633313237343833373316f4f99e97cd6216008215003b01880b6532656556657273696f6e01321300195810bf550ec885eddf3b2e0ca300f4003fe61fd5c844517919238538e71b3c63e675c0a956c7a0c48159edf953ce330508e70c0000000000000001f7acec1e040043a9a1040043a290790c000016f81016dcdda297cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373136393938383830333731363735323616d4dda297cd6216008215003b01880b6532656556657273696f6e01321300195810ef6915aafcdf5659f31a8ff0cd5997251cb8c56691f750fa9cd79951fa8f3b67afac3999da42db0bb5dbe4635c0c000000000000000e07f86fff040043a290040043a9a1790c000016fa1016a0e8a497cd62155015a29c01682175353163386666323362343539346663623166336630313337383033666233336318123437313639393838383033373136373532361801300016fc1016eca4a597cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373136393939323331353133353632333716e4a4a597cd6216008215003b01880b6532656556657273696f6e013213001958108f18c95e47d574d610e88ca2f4e766a11ca573f2843356dd9d144e3d195677815ec86a628890d433d54d9aec820c000000000000000f44246c8b040043a290040043a9a1790c000016fe10169ed0a597cd62155015a69c01682175353163386666323362343539346663623166336630313337383033666233336318123437313639393932333135313335363233371801300016801116d0fea597cd6215321536680130ac182175393536343963623937663839316464663663626336616265653334636165393718217535316338666632336234353934666362316633663031333738303366623333631500181234373136393939333331313732383434333316cafea597cd6216008215003b01880b6532656556657273696f6e01321300195810041cdcd99aad5248bdd2ad849eae4e8f1d4d846a2755a4e3b56ec3969e7627184af23949f88c631039ba35c82c300c00000000000000023f5e3fc6040043a9a1040043a290790c0000168411168ab2ab97cd6215341500680130ac18217535316338666632336234353934666362316633663031333738303366623333631821753935363439636239376638393164646636636263366162656533346361653937150018123437313730303030373135343631343432341682b2ab97cd6216008215003b01880b6532656556657273696f6e013213001958109fa74c6237c0d55afc2fd273955d51ec1cc028a481b3e38beaa177a8766f59bb087cfa155f087a1184184c74220c00000000000000104d4bd486040043a290040043a9a1790c00001686111684d7b597cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137303031343834383634303631353116fcd6b597cd6216008215003b01880b6532656556657273696f6e01321300195810057a39635effaeb406f955099c4da6a71c5d3a0201fb5888cb8f0aca8b0472aa86203cf74f6f4a1966c6bb7c8f0c0000000000000011976a9b43040043a290040043a9a1790c00001688111698afb697cd62156215a89c01682175353163386666323362343539346663623166336630313337383033666233336318013100168a111694c3b697cd62155015aa9c016821753531633866663233623435393466636231663366303133373830336662333363181234373137303031343834383634303631353118013000168c1116f2aabe97cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137303032363735383738363238363616daaabe97cd6216008215003b01880b6532656556657273696f6e013213001958100e5b1d1871cdf9b1272f185175a7baa51dbd889cd1dbdaba307fd0adb164471b661a1ad2ec7e54d0a82e9b7a52cd0c0000000000000012e497a48c040043a290040043a9a1790c0000168e1116deb4c097cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137303032393630393233353239383116d6b4c097cd6216008215003b01880b6532656556657273696f6e013213001958100a76babbad2e6e66aa64b55db10d7d151cb6cd7389a28897446f022b944cc575d078c9bac70de05318e7ae69d10c000000000000001362400999040043a290040043a9a1790c000016901116ac82cb97cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137303034343139303238373436353816a482cb97cd6216008215003b01880b6532656556657273696f6e01321300195810f92115db14be5ba642b264ce22bd077a1de75d6ce7786e240dff9f80fc693f564c5cca9305f7e7c15a06465a41ec0c0000000000000014927e1131040043a290040043a9a1790c0000169211169898cc97cd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731373030343538303432323934333339169098cc97cd6216008215003b01880b6532656556657273696f6e01321300195810139dc73a45ef77545c15ddc6c22776a11ceb63d2443a0fc8d70166ab90cc4036ff3a98eaaabf98652ec0ba81d90c000000000000001512dfdcaf040043a290040043a9a1790c00001694111698bace97cd6215341500680130ac18217535316338666632336234353934666362316633663031333738303366623333631821753935363439636239376638393164646636636263366162656533346361653937150018123437313730303438393033303539393033311692bace97cd6216008215003b01880b6532656556657273696f6e01321300195810bf5cd98d7e357d98d8182aa75c51b5001d4d664cb2d8f6f08217b5e224acd8df86cdd08b85826cdd0bc011de21d40c00000000000000166df9d161040043a290040043a9a1790c00001696111694ead097cd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731373030353231373435393038303337168cead097cd6216008215003b01880b6532656556657273696f6e01321300195810e221a77af928ed1106da7ced2d55352e1c4108024c43bdf51abd1f3ff8b43df8f3be9a38f5a31d95003baf44d00c0000000000000017ef8b00c2040043a290040043a9a1790c000016981116fedcd497cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137303035373531393735393336303516f6dcd497cd6216008215003b01880b6532656556657273696f6e0132130019581091cb45bfae2d91ce6905ae60f4ca109c1cc6262f0d1d80dbb04470e7a1cd783597b1a3e472aae01cd753dbffc30c0000000000000018ac3be10d040043a290040043a9a1790c0000169a11168e86dc97cd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731373030363735383737363636393831168686dc97cd6216008215003b01880b6532656556657273696f6e01321300195810ca8dc1843d65045a4ce687a4688afa8b1cc5e1ce055714b84e5623ea23d759c29457bfaf6256ba4d10f3d6cbe90c000000000000001979e6f02d040043a290040043a9a1790c0000169c11169aa9dc97cd62155015f4ab016821753531633866663233623435393466636231663366303133373830336662333363181234373137303036373538373736363639383118013000169e1116d8cedc97cd621532154c680130ac182175393536343963623937663839316464663663626336616265653334636165393718217535316338666632336234353934666362316633663031333738303366623333631500181234373137303036383338383039323332353116d2cedc97cd6216008215003b01880b6532656556657273696f6e0132130019581041d78526a62344e565d70012b701c56122bc89d3f4b50d2edde4d3f03c519353357e6bd767d7516bd7771fe22a6df1a6018c6b0c0000000000000003ba059cda040043a9a1040043a290790c000016a21116b4ebdc97cd621532154e680130ac182175393536343963623937663839316464663663626336616265653334636165393718217535316338666632336234353934666362316633663031333738303366623333631500181234373137303036383636333236343930373716b0ebdc97cd6216008215003b01880b6532656556657273696f6e0132130019581026c5ba42336e112abf1966e1d36136ae1e03d36c3e4270131a605140b9baed60c78fff9422f31443bd6f5c967758aa0c00000000000000046620e664040043a9a1040043a290790c000016a61116ae8c839bcd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137303634393033323433383630353116a68c839bcd6216008215003b01880b6532656556657273696f6e013213001958106c3a0e25b0ad6db3a251330f9febc31e1cc86b7bba6e5811981dae51536406dc0f3550b8a95511de3acf73fed70c000000000000001a41396bf8040043a290040043a9a1790c000016a811168a92839bcd62155015f6ab01682175353163386666323362343539346663623166336630313337383033666233336318123437313730363439303332343338363035311801300016aa111694e78a9bcd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731373036353936323035313333383931168ae78a9bcd6216008215003b01880b6532656556657273696f6e013213001958104e18ab8abf1ad429f19909fd7910877d1ca7e194564ad53d4899a57770950bab5ce0cb9a24ea9f28a276ff3a520c000000000000001bfff2932d040043a290040043a9a1790c000016ac1116bedccf9ecd6215501592cb01682175353163386666323362343539346663623166336630313337383033666233336318123437313730363539363230353133333839311801300016ae111680acd09ecd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313238323934343434353636303316f8abd09ecd6216008215003b01880b6532656556657273696f6e013213001958101293a29cc578bdec587154388ece5d681caad41df4bfe834651ae3293a05b630f052be8c5ace5a0258d298bf140c000000000000001c6e477406040043a290040043a9a1790c000016b01116a0d4d09ecd6215501596cb01682175353163386666323362343539346663623166336630313337383033666233336318123437313731323832393434343435363630331801300016b21116e6ecd69ecd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313239313930383531323137333216deecd69ecd6216008215003b01880b6532656556657273696f6e013213001958103e53650e2ebeac191e866c042194ffa01c9efb5d6a66c598caa769f4e9eb98650b0f16e25167044aa60022f0750c000000000000001df76d83c1040043a290040043a9a1790c000016b41116fcafea9ecd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313331383732313838343939393716f4afea9ecd6216008215003b01880b6532656556657273696f6e01321300195810563706c0d4f01fbc150ea5562fe14a741cd72bdba7daba6298a9c9a1ba5f9940d5458af0c6d8dcc4bdb88345e20c000000000000001efd87ef95040043a290040043a9a1790c000016b611168ac8ee9ecd6215341500680130ac18217535316338666632336234353934666362316633663031333738303366623333631821753935363439636239376638393164646636636263366162656533346361653937150018123437313731333234353038333230353938351682c8ee9ecd6216008215003b01880b6532656556657273696f6e01321300195810dd26c3ae21a6b876b29964267d0a93ef1c16771e736707c05c425bd66acaf0acf66b65dc3fe1fe5a47bea3d28e0c000000000000001f462b6ab0040043a290040043a9a1790c000016b811169cabf09ecd6215341500680130ac18217535316338666632336234353934666362316633663031333738303366623333631821753935363439636239376638393164646636636263366162656533346361653937150018123437313731333236393435393937363233301694abf09ecd6216008215003b01880b6532656556657273696f6e01321300195810c96071982b8251e0673ed371c47ea2c21c3647c9cb31402c831b8145029d16353bb920b6abf38779d67ab46f5c0c00000000000000200f3ae785040043a290040043a9a1790c000016ba1116dce8959fcd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313337383433333637343437343616d6e8959fcd6216008215003b01880b6532656556657273696f6e0132130019581031c28ccd4c7ab9aa45e1f134a57187d91c9dbec0ad42b4b4ef1a887c9b3737e1e35a5858a40beb7cf9e27b95230c00000000000000219067c131040043a290040043a9a1790c000016bc1116c2caad9fcd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313431313039303439393231353116bacaad9fcd6216008215003b01880b6532656556657273696f6e013213001958103104b1717cce9b455ce19b6aec6732121c8b8429926167bea0c98771d60a0a129f6f7e529243c017b456981ebf0c0000000000000022cfb5268f040043a290040043a9a1790c000016be1116cce6af9fcd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313431343136353731303438323316c4e6af9fcd6216008215003b01880b6532656556657273696f6e01321300195810f31de17d0b1135694536e2de7db82c781c6e02129f67c986d6a059a941bed7daec1c2353dc1082ad8000d917040c00000000000000236ac469e2040043a290040043a9a1790c000016c0111696cce79fcd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731373134393038323538363937363735168ecce79fcd6216008215003b01880b6532656556657273696f6e01321300195810d017b466b83d6ab4f696632ca30f4af71c85434f656405f8c0f11da6863b0e9bd0d0b173515c965ec8b2a175ec0c000000000000002456b4cfca040043a290040043a9a1790c000016c21116c29f8fa0cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313534353331393937313236393716ba9f8fa0cd6216008215003b01880b6532656556657273696f6e013213001958107ed725b017894a1318fadfd6ae10bdeb1c138f975b077dbec3a5ee8b83240af948b9383cdf02459e66368e916e0c0000000000000025a44ebc94040043a290040043a9a1790c000016c41116c0e4b1a1cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373137313736383732303334363336303716b6e4b1a1cd6216008215003b01880b6532656556657273696f6e0132130019581088876c5413bac09a7d6c2944d03faf7620590d385df40aec6ce1bfb0bfb1500a3ac99d39a28d573c7cbc5994e5f97215790c000000000000002652ff0470040043a290040043a9a1790c000016c61116f692d5a2cd62155015d48902682175353163386666323362343539346663623166336630313337383033666233336318123437313731373638373230333436333630371801300016c81116eabfa4ebcd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138343736383638323035393432323816e0bfa4ebcd6216008215003b01880b6532656556657273696f6e01321300195810a4d760bd2951844fabf8864646f887f824e1664fd178b6b43ca95e7ed56e45dd27713b2bbdf5e87d73deb2d8543efb1072144474710c000000000000002763c588f4040043a290040043a9a1790c000016ca1116cebed8efcd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353534333832363337343639333316c6bed8efcd6216008215003b01880b6532656556657273696f6e01321300195810e23793f3d00cb4df232929594983269f213a35dae169829693c824a6b4a4435ada4e3c0f1ba8310dacb89961002f8220e0d70c000000000000002828864fbd040043a290040043a9a1790c000016cc1116ccfcddefcd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353535313334393237383332383916c6fcddefcd6216008215003b01880b6532656556657273696f6e0132130019581078d6bfbd0fa40c627df404d803e6ef852d3a89804628248d7ef56067a2515914f3a6d8115f039e4e17099930c5e1e7d7321884e4adf4d8c042b497c90df20c0000000000000029c21ff85b040043a290040043a9a1790c000016ce1116f2e5e6efcd62155015f4a802682175353163386666323362343539346663623166336630313337383033666233336318123437313835353531333439323738333238391801300016d011169ce0e8efcd6215341500680130ac18217535316338666632336234353934666362316633663031333738303366623333631821753935363439636239376638393164646636636263366162656533346361653937150018123437313835353636313932303535313238311694e0e8efcd6216008215003b01880b6532656556657273696f6e013213001958108c705cd0eceadf61ed854d88dccc237f1c57f6a9d2b1722181878f06e267ead6014f8c05b2e24add1b4f671acf0c000000000000002a326ace7a040043a290040043a9a1790c000016d2111694f3f3efcd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731383535383135313330303837393035168af3f3efcd6216008215003b01880b6532656556657273696f6e0132130019581020963ed03605919dc34b1b140978ddc620491824529e0bb35da543ef5b4ce5e4b4300f7e8a80138f6cac930697e97b1ef50c000000000000002b583592a1040043a290040043a9a1790c000016d41116ce9784f0cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353630333839353439323633333716c49784f0cd6216008215003b01880b6532656556657273696f6e01321300195810f8446c3ea3d1b71e9d2d0515b3f9bf9121745e1bc42d5fe2e4cb7b889ac923ccec28cdb560b2aed2bb964e39d8f0b9d9f9160c000000000000002c242e0f28040043a290040043a9a1790c000016d61116d0f98df0cd62155015c4b802682175353163386666323362343539346663623166336630313337383033666233336318123437313835363033383935343932363333371801300016d81116a0a78ef0cd6215321576680130ac1821753935363439636239376638393164646636636263366162656533346361653937182175353163386666323362343539346663623166336630313337383033666233336315001812343731383536313737383730323734393833169ca78ef0cd6216008215003b01880b6532656556657273696f6e013213001958103b1d6ddd77700ba96bfeaa197bf234ca1f6f91c09c09b6b93fe28e3c5e25e77d6ae3777200dc9b7431f7653a29af77e10c00000000000000055fbe7a78040043a9a1040043a290790c000016da1116c6ab8ef0cd62156e15006821753531633866663233623435393466636231663366303133373830336662333363182175353163386666323362343539346663623166336630313337383033666233336318123437313835363137373837303237343938330016dc1116fa9399f0cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353633323731383734393730383916f29399f0cd6216008215003b01880b6532656556657273696f6e0132130019581087f83d25772a03988c4971b13d0180901d5388495befbb64179b8d2f387b582b4d0bc73438000ca3cfcdeb5486100c000000000000002d8adde06e040043a290040043a9a1790c000016de1116dac69ef0cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353634303130323432383637373416d2c69ef0cd6216008215003b01880b6532656556657273696f6e0132130019581067086fa09fd0ec73f4546991e7b34c751dbf7b85fbd0c327897a3248870052a1f916932cf3c59aabd0da4bd737950c000000000000002e2a863b9a040043a290040043a9a1790c000016e0111688eba7f0cd6215341500680130ac18217535316338666632336234353934666362316633663031333738303366623333631821753935363439636239376638393164646636636263366162656533346361653937150018123437313835363532383833333131383232391682eba7f0cd6216008215003b01880b6532656556657273696f6e01321300195810768c15c7a8c974403e9acd1aa2d52e8b1d0e7ea8b53c7159d97f85d5ee69140b013be347bd52c38f675a2bb6538f0c000000000000002f56c6ce70040043a290040043a9a1790c000016e211168ea2daf0cd6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313835363332373138373439373038391801300016e41116d689e2f0cd6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313835363430313032343238363737341801300016e61116c88be2f0cd6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313835363532383833333131383232391801300016e8111684fefdf0cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353737313237383432313233353416fefdfdf0cd6216008215003b01880b6532656556657273696f6e01321300195810721f9da3ab8b0b344dc8a89a72f4afd11d54e85dbf1739b8c09d5816107db464c48eee28e9cf11545aadc30a4ce70c000000000000003030c0b942040043a290040043a9a1790c000016ea1116a2cca1f1cd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731383538323032303931343534373036169acca1f1cd6216008215003b01880b6532656556657273696f6e01321300195810a3491532c4f6d03b331fe8bfd3612edc211868d3bc73e531f5ce0e6d6a6ece3360e01f1e8f8aca3e0c3c3679f7377420f2970c000000000000003189b5e1d8040043a290040043a9a1790c000016ec1116928dfcf1cd6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731383539343436323536353031323335168a8dfcf1cd6216008215003b01880b6532656556657273696f6e01321300195810fde4d4d33fbdd72990661fcb083526ed1e602d8f4b5c2db436d9222f7dac5d2a0637c0a0ef8b2b8def183e0f3a715f0c00000000000000323f598e7f040043a290040043a9a1790c000016ee1116e0a7fcf1cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353934343931373537333634393716d8a7fcf1cd6216008215003b01880b6532656556657273696f6e01321300195810f2db0a2e028c8ad1ef172f92f7019b411ec7936131f177007554c83442854d3e0b7e4b98791675cc4b2afc9cbe8cf40c00000000000000331061ee6e040043a290040043a9a1790c000016f01116f4ecfff1cd6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373138353934393736323738313230313016ececfff1cd6216008215003b01880b6532656556657273696f6e01321300195810873717014aa00ea8f6b5bfb58182bcb029e27fbeb48ae3a6e829fe52d51ff7d880e62d292e269849e34fa6210d9c2a6088729de8989f7dc3b43b0c000000000000003482cda571040043a290040043a9a1790c000016f21116b6b7ecbcce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393131373231383233313132363816aeb7ecbcce6216008215003b01880b6532656556657273696f6e01321300195810c973e26eec1d76ebeb1a1c033c908a20293961ab2e6098d3dc80129d3d1e750bc09aec6336a69034908d0496f0b566f0b15f0f3d1140bcc092010c0000000000000035facb719e040043a290040043a9a1790c000016f41116c8b2f5bcce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939313137323138323331313236381801300016f61116c899fcbcce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393133383838393330383539313416c299fcbcce6216008215003b01880b6532656556657273696f6e01321300195810b2a6bb0986150027b6fdf49c8eae7c92249926e5cb1bfbe719c16309d8bae2a9439055b0478f39004dcef25eb46853e278d882cd150c00000000000000363ee87152040043a290040043a9a1790c000016f81116ea89fcbdce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939313338383839333038353931341801300016fa1116948cfcbdce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939313137323138323331313236381801300016fc1116829887bece6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393332393932383133373936303116fa9787bece6216008215003b01880b6532656556657273696f6e0132130019581008138ef7801d372d719b5d24173a5db72790d3517b5d554f2cc3c22315894eb1c02a50ff05f5581ea7d6856a0d87d4f0eb75c0a927aa84d50c000000000000003757b5a3e6040043a290040043a9a1790c000016fe1116beef9abece6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939333239393238313337393630311801300016801216e49aa2bece6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939313137323138323331313236381801300016821216e89ca2bece62155015006821753531633866663233623435393466636231663366303133373830336662333363181234373139393133383838393330383539313418013000168412169a86a5bece62155015006821753531633866663233623435393466636231663366303133373830336662333363181234373139393131373231383233313132363818013000168612168c88a5bece6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939313338383839333038353931341801300016881216ccf4b4c0ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393734343539383834313739323916c4f4b4c0ce6216008215003b01880b6532656556657273696f6e01321300195810b261ecaf1657208e0a396f3784c9b3332632a9100b804509414f1dc2c37819d3ec58dc36aa7b0ecae9d2e68948b0d66877d7cce8c214b10c0000000000000038a0977c32040043a290040043a9a1790c0000168a1216d8e4e8c0ce62155015006821753531633866663233623435393466636231663366303133373830336662333363181234373139393734343539383834313739323918013000168c1216baa0eac0ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393831373932333636343239333416b2a0eac0ce6216008215003b01880b6532656556657273696f6e013213001958109bebbad474547db00603eafbd7d60e4e296ebe7e1d353db79abb9f0d234bceb85151e8788975a78481c0971053f6840ae2837fa5cb4f97dd37290c000000000000003985761e45040043a290040043a9a1790c0000168e1216baf0eac0ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393831383738363031333231373716b2f0eac0ce6216008215003b01880b6532656556657273696f6e013213001958100024e4f8533f169fbcdbbdeda9dfe79a213f636cb946daa9278ea22bbad6a3c65962229ad54923e603f605b622fc5232ad9d0c000000000000003ac43dba19040043a290040043a9a1790c000016901216eaa0ebc0ce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939373434353938383431373932391801300016921216d4c7f1c0ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393832373936383138333534373316cac7f1c0ce6216008215003b01880b6532656556657273696f6e013213001958105bec00a61fc2d9548d5db5bb0288a553240d8a537ed84b1b4b84f13f38ceaf5e3e234d50936ea5c3b6262b76432e06fc05a814b8c90c000000000000003b7695802e040043a290040043a9a1790c000016941216a4d2f2c0ce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939383237393638313833353437331801300016961216c88ef5c0ce62155015006821753531633866663233623435393466636231663366303133373830336662333363181234373139393832373936383138333534373318013000169812169a86f6c0ce6215341500680130ac1821753531633866663233623435393466636231663366303133373830336662333363182175393536343963623937663839316464663663626336616265653334636165393715001812343731393938333431313139343736313534169286f6c0ce6216008215003b01880b6532656556657273696f6e013213001958103f9a51ba89a5106bdcd3a4c726279d202d5cc422d00cb5d3cd79f9cd1dc27ebc373e3680d1b17776ec29b5b7032a0d9cd30f2375d307c9e8f786899c04bd0c000000000000003c7b57237a040043a290040043a9a1790c0000169a1216eccaf7c0ce62155015006821753531633866663233623435393466636231663366303133373830336662333363181234373139393833343131313934373631353418013000169c1216acecb6c1ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393932333137383833313837323516a6ecb6c1ce6216008215003b01880b6532656556657273696f6e0132130019581077f0459b731bd6abe2fdcdaeb3ab1cff2781e756c85de0f1a971f5ec3b4121a31096ea4679711a5b4dae1c69842c5f56696e9cbc1e778b610c000000000000003d4e309241040043a290040043a9a1790c0000169e1216c4adbac1ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393932383031323334373833343316bcadbac1ce6216008215003b01880b6532656556657273696f6e013213001958101c25ce0324c48ad0089b8bcdeb9dc4cb27f847d8c73375e07b53069a3ee5be0e66bfbb25d96c4dbe8c675c39b33e91bceba953f49444b39e0c000000000000003ef43c23e4040043a290040043a9a1790c000016a01216caebbac1ce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939393238303132333437383334331801300016a21216bca7bdc1ce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939393238303132333437383334331801300016a41216e8d3c3c1ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393934303739343930383638363716e0d3c3c1ce6216008215003b01880b6532656556657273696f6e013213001958105c23fd84e0391daa5bd5ff001d42c52a248dabdda8ea4fbf60938fce810375f56c9027606ca218023e1c01b9971e6f31fb088d90520c000000000000003fd3fa6df5040043a290040043a9a1790c000016a612168e9ec7c1ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373139393934353639333838313938313416869ec7c1ce6216008215003b01880b6532656556657273696f6e0132130019581005f8941a28fc77c49854c3541f2551b82a1aebba64c47fac84372644782760cd0a61ac27da5a267c51e25e657ceca32966abaef8f645b26bee81d30c0000000000000040dc795b7f040043a290040043a9a1790c000016a81216eec6c8c1ce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939393435363933383831393831341801300016aa12168c83cbc1ce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437313939393435363933383831393831341801300016ac1216bec8b5c5ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373230303632353130303636353639313916b8c8b5c5ce6216008215003b01880b6532656556657273696f6e0132130019581099aebffaabd52e5f2daf03f7682a12412d4dfc08ec48ddfb36def913cd65867af18def32587e6b8992c5bc0c9b6004f5cf78406b94411893d306cd18fccb0c0000000000000041ab15d608040043a290040043a9a1790c000016ae121690fab6c5ce6215501500682175353163386666323362343539346663623166336630313337383033666233336318123437323030363235313030363635363931391801300016b01216c6d6b7c5ce6215341500680130ac182175353163386666323362343539346663623166336630313337383033666233336318217539353634396362393766383931646466366362633661626565333463616539371500181234373230303632383031333234323738323916c0d6b7c5ce6216008215003b01880b6532656556657273696f6e013213001958104b089ab1a2db7ab423be26a4c66c529321278229457ab4570ff8f54515625885cb0517dbc1540e2facc79f5014e296f532620c0000000000000042a84d8702040043a290040043a9a1790c000016b21216a4b6b9c5ce62155015006821753531633866663233623435393466636231663366303133373830336662333363181234373230303632353130303636353639313918013000111c1b095c1615161500157816f4a089b4d0621200301530154615ae0316f6d0b887d06212000215021500153c16cab2d198d0621100081508151415e802168af0b2add0621200121512154615ae0316dec6ded4cd6212000e150e1500151416e0969ab9c7621200521552150a157816f4a2e2f3cd621200061506154615ae031692a6f39ed0621200581558151415e802168ec99aadd06212001688d88601001c1a1580801016ea0100000000")
api := thrifter.Config{Protocol: thrifter.ProtocolCompact}.Froze()
var msg general.Message
err := api.Unmarshal(body, &msg)
if err != nil {
	fmt.Println("Unmarshal err", err)
	return
}
fmt.Println(msg)

test/level_2/list_of_map_test.go Test_marshal_list_of_map case panic

a64af9d 这个commit可以修复这个panic,但是导致了其他test case panic....

=== RUN   Test_marshal_list_of_map
unexpected fault address 0x602be40
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x602be40 pc=0x580eda]

goroutine 9 [running]:
runtime.throw(0x99a3a6, 0x5)
	/home/ck/go/src/runtime/panic.go:616 +0x81 fp=0xc4200a19c0 sp=0xc4200a19a0 pc=0x5a3101
runtime.sigpanic()
	/home/ck/go/src/runtime/signal_unix.go:395 +0x211 fp=0xc4200a1a10 sp=0xc4200a19c0 pc=0x5b9431
runtime.evacuated(...)
	/home/ck/go/src/runtime/hashmap.go:198
runtime.mapiternext(0xc4200c33e0)
	/home/ck/go/src/runtime/hashmap.go:771 +0x49a fp=0xc4200a1aa0 sp=0xc4200a1a10 pc=0x580eda
runtime.mapiterinit(0x922740, 0xc4200a56c0, 0xc4200c33e0)
	/home/ck/go/src/runtime/hashmap.go:737 +0x1f1 fp=0xc4200a1ac8 sp=0xc4200a1aa0 pc=0x580951
reflect.mapiterinit(0x922740, 0xc4200a56c0, 0x15)
	/home/ck/go/src/runtime/hashmap.go:1217 +0x54 fp=0xc4200a1af8 sp=0xc4200a1ac8 pc=0x582074
reflect.Value.MapKeys(0x922740, 0xc4200a56c0, 0x15, 0xc4200a56c0, 0x15, 0x5)
	/home/ck/go/src/reflect/value.go:1114 +0xdd fp=0xc4200a1ba0 sp=0xc4200a1af8 pc=0x62a54d
github.com/thrift-iterator/go/binding/reflection.(*mapEncoder).encode(0xc420179710, 0xc4200a56c0, 0x9ea0a0, 0xc4200e6460)
	/home/ck/work/src/github.com/thrift-iterator/go/binding/reflection/encode_map.go:21 +0x9f fp=0xc4200a1c60 sp=0xc4200a1ba0 pc=0x8a85ef
github.com/thrift-iterator/go/binding/reflection.(*sliceEncoder).encode(0xc420179740, 0xc42018e420, 0x9ea0a0, 0xc4200e6460)
	/home/ck/work/src/github.com/thrift-iterator/go/binding/reflection/encode_slice.go:21 +0xa3 fp=0xc4200a1ca0 sp=0xc4200a1c60 pc=0x8a8fc3
github.com/thrift-iterator/go/binding/reflection.(*valEncoderAdapter).Encode(0xc4200a56f0, 0x9020e0, 0xc42018e420, 0x9ea0a0, 0xc4200e6460)
	/home/ck/work/src/github.com/thrift-iterator/go/binding/reflection/unsafe.go:45 +0x51 fp=0xc4200a1cd0 sp=0xc4200a1ca0 pc=0x8a92c1
github.com/thrift-iterator/go.(*frozenConfig).Marshal(0xc42017ee40, 0x9020e0, 0xc42018e420, 0xc42018e460, 0x2, 0xc42018e440, 0x1, 0x2)
	/home/ck/work/src/github.com/thrift-iterator/go/config.go:258 +0x113 fp=0xc4200a1d60 sp=0xc4200a1cd0 pc=0x8b2b43
github.com/thrift-iterator/go/test.glob..func5(0x9020e0, 0xc42018e420, 0x9020e0, 0xc42018e420, 0xc42008fe01, 0x588cb8, 0x6607ed)
	/home/ck/work/src/github.com/thrift-iterator/go/test/combinations.go:35 +0x257 fp=0xc4200a1e40 sp=0xc4200a1d60 pc=0x8b54e7
command-line-arguments.Test_marshal_list_of_map(0xc4201805a0)
	/home/ck/work/src/github.com/thrift-iterator/go/test/level_2/list_of_map_test.go:98 +0x32c fp=0xc4200a1fa8 sp=0xc4200a1e40 pc=0x8bb22c
testing.tRunner(0xc4201805a0, 0x9b2cb0)
	/home/ck/go/src/testing/testing.go:777 +0xd0 fp=0xc4200a1fd0 sp=0xc4200a1fa8 pc=0x660890
runtime.goexit()
	/home/ck/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200a1fd8 sp=0xc4200a1fd0 pc=0x5d2781
created by testing.(*T).Run
	/home/ck/go/src/testing/testing.go:824 +0x2e0

panic:when nested struct

type A struct {
  Member *B
}

type B struct {
  NextA map[string]*A
}

Use any A obj, thrifter.Marshal would run out of memory.

generalListDecoder panics when iterator timeout on decoding message

When decoding a message, the Decoder.Decode method is called. (the following code snippet)

Line 24 (L24) tries to decode the message, and it will check the error of iter on decoding finished (L25). However, the L24 may panic (instead of return normally). When the L24 panics, the whole method will panic, not returning the expected error.

go/decoder.go

Lines 16 to 29 in 9b5a675

func (decoder *Decoder) Decode(val interface{}) error {
cfg := decoder.cfg
valType := reflect.TypeOf(val)
valDecoder := cfg.getGenDecoder(valType)
if valDecoder == nil {
valDecoder = cfg.decoderOf(valType)
cfg.addGenDecoder(valType, valDecoder)
}
valDecoder.Decode(val, decoder.iter)
if decoder.iter.Error() != nil {
return decoder.iter.Error()
}
return nil
}

Following is the method where panic may occur.

The underlying Reader of iter may read from a TCP connection (L13). But TCP connection can run timeout, then the underlying Reader will get an error. When such error occurs, the iter will return zero values and set an error. (thus elemType == TypeStop && length == 0 && iter.Error() != nil) When trying to get the generalReaderOf(TypeStop) (L14), this method will panic (See the code snippet, go/general/decode.go#L31).

func (decoder *generalListDecoder) Decode(val interface{}, iter spi.Iterator) {
*val.(*List) = readList(iter).(List)
}
func readList(iter spi.Iterator) interface{} {
elemType, length := iter.ReadListHeader()
generalReader := generalReaderOf(elemType)
var generalList List
for i := 0; i < length; i++ {
generalList = append(generalList, generalReader(iter))
}
return generalList
}

go/general/decode.go

Lines 8 to 33 in 9b5a675

func generalReaderOf(ttype protocol.TType) func(iter spi.Iterator) interface{} {
switch ttype {
case protocol.TypeBool:
return readBool
case protocol.TypeI08:
return readInt8
case protocol.TypeI16:
return readInt16
case protocol.TypeI32:
return readInt32
case protocol.TypeI64:
return readInt64
case protocol.TypeString:
return readString
case protocol.TypeDouble:
return readFloat64
case protocol.TypeList:
return readList
case protocol.TypeMap:
return readMap
case protocol.TypeStruct:
return readStruct
default:
panic("unsupported type")
}
}

比官方thrift快的原理是什么?

请问,官方库是静态生成的go code序列化反序列化,thrift-iterator是用反射动态运行时序列化反序列化,为什么后者更快呢?

使用go mod提示错误

github.com/thrift-iterator/go imports
github.com/v2pro/wombat/generic imports
github.com/v2pro/plz/countlog imports
github.com/v2pro/plz/countlog/stats tested by
github.com/v2pro/plz/countlog/stats.test imports
github.com/v2pro/plz/countlog/core: module github.com/v2pro/plz@latest found (v0.0.0-20180227161703-2d49b86ea382), but does not contain package github.com/v2pro/plz/countlog/core

Feature List

Protocol

Binary Compact
Decode []byte Yes Yes
Decode io.Reader Yes TODO
Encode Yes Yes

API Styles

  • Iterator/Stream: low level spi
  • Object: decode/encode with generic object model ([]interface{}, map[interface{}]interface{}, map[protocol.FieldId]interface{})
  • Static codegen: generate code to decode/encode, to support object binding
  • Dynamic codegen: generate the code in the runtime, to support object binding
Simple Value List Map Struct Pointer Message RawMessage
Iterator / Decode Yes Yes Yes Yes N/A Yes Yes
Stream / Encode Yes Yes Yes Yes N/A Yes Yes
Object / Decode Yes Yes Yes Yes N/A Yes N/A
Object / Encode Yes Yes Yes Yes N/A Yes N/A
Static / Decode Yes Yes Yes Yes Yes N/A TODO
Static / Encode Yes Yes Yes Yes Yes N/A TODO
Dynamic / Decode Yes Yes Yes Yes Yes N/A TODO
Dynamic / Encode Yes Yes Yes Yes Yes N/A TODO

Please correct some small errors in Readme

In section Partial Decoding, there is one line which could not run correctly.

decoder := thrifter.NewDecoder(reader)
should be
decoder := thrifter.NewDecoder(reader, nil)

panic: unsupported type when decoding data (Need Sets support)

Here is data which i'm trying to decode:

Data in hex 800100020000001961757468656e7469636174654c6f6e6753657373696f6e5632000000000c00000a00010000017882717cab0b00020000006c533d733430383a553d643664396431393a453d31633165663564333461623a433d31373838323731376433383a503d3164643a413d656e2d696f732d78617574682d6e65773a563d323a483d64343966303064303839613531303434396364383538326138346133333536320a0003000001c1ef5d34ab0c00040800010d6d9d190b00020000000a7261736f726f383936340b0003000000167261736f726f3839363440697261686164612e636f6d080007000000010a000900000178826ce1880a000a00000178826ce18802000d010b000e00000004733430380c000f020004010b0006000000127261736f726f383936342e333134316163340b00140000000272750a002400000178826ce188000c00100a00010000000003c000000a0002000001792193b9800a00030000000003c00000080004000000000a000e00000178826ce1880800130000000008001700000000000c00110a00010000017882717d5602000200020003000200050002000600020007000200080002000b01000b00130000003868747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f757365722f3232353238373434392f70686f746f080015000000010c0016080001000000320a000200000000019000000a00030000000001900000080004000000640a00050000000003c00000080006000186a0080007000000fa080008000186a00800090000006408000a0000006408000b000003e808000c0000000208000d0000000208000e00000000000c00170a00010000017882717d57020002000200030002000500020006000e0007080000000200000002000000030a00090000017fda22a95702000a00000c001802000101020002000a000300000178826ce1880002001901000b00060000002d68747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f6e6f746573746f72650b00070000002468747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f0c000a0b00010000002d68747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f6e6f746573746f72650b00020000002468747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f0b00030000002d68747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f6564616d2f757365720b00040000002b68747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f7574696c6974790b00050000003068747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f6d65737361676573746f72650b0006000000237773733a2f2f77732e657665726e6f74652e636f6d2f73686172642f733430382f69640b00070000003768747470733a2f2f7777772e657665726e6f74652e636f6d2f73686172642f733430382f636f6d6d756e69636174696f6e656e67696e650b00080000004068747470733a2f2f64617368626f6172642e7376632e7777772e657665726e6f74652e636f6d2f76312f6d61696e2e68746d6c233f763d64617368626f6172640b00090000004668747470733a2f2f64617368626f6172642e7376632e7777772e657665726e6f74652e636f6d2f76312f6d61696e2e68746d6c233f763d73706163652d6469726563746f7279000000
It's okay with another server responses, although, burp suite extension https://github.com/mdsecresearch/ThriftDecoder decodes it perfectly
Decoded data
{
    "method": "authenticateLongSessionV2", 
    "length": 1321, 
    "type": "reply", 
    "args": {
        "fields": [
            {
                "field_id": 0, 
                "field_type": "struct", 
                "value": {
                    "fields": [
                        {
                            "field_id": 1, 
                            "field_type": "i64", 
                            "value": 1617096413224
                        }, 
                        {
                            "field_id": 2, 
                            "field_type": "string", 
                            "value": "S=s408:U=d6d9d19:E=1c1ef60c828:C=17882750f48:P=1dd:A=en-ios-xauth-new:V=2:H=b5946af0e630ce30df9e5c5c38961a07"
                        }, 
                        {
                            "field_id": 3, 
                            "field_type": "i64", 
                            "value": 1932456413224
                        }, 
                        {
                            "field_id": 4, 
                            "field_type": "struct", 
                            "value": {
                                "fields": [
                                    {
                                        "field_id": 1, 
                                        "field_type": "i32", 
                                        "value": 225287449
                                    }, 
                                    {
                                        "field_id": 2, 
                                        "field_type": "string", 
                                        "value": "rasoro8964"
                                    }, 
                                    {
                                        "field_id": 3, 
                                        "field_type": "string", 
                                        "value": "[email protected]"
                                    }, 
                                    {
                                        "field_id": 7, 
                                        "field_type": "i32", 
                                        "value": 1
                                    }, 
                                    {
                                        "field_id": 9, 
                                        "field_type": "i64", 
                                        "value": 1617095877000
                                    }, 
                                    {
                                        "field_id": 10, 
                                        "field_type": "i64", 
                                        "value": 1617095877000
                                    }, 
                                    {
                                        "field_id": 13, 
                                        "field_type": "bool", 
                                        "value": true
                                    }, 
                                    {
                                        "field_id": 14, 
                                        "field_type": "string", 
                                        "value": "s408"
                                    }, 
                                    {
                                        "field_id": 15, 
                                        "field_type": "struct", 
                                        "value": {
                                            "fields": [
                                                {
                                                    "field_id": 4, 
                                                    "field_type": "bool", 
                                                    "value": true
                                                }, 
                                                {
                                                    "field_id": 6, 
                                                    "field_type": "string", 
                                                    "value": "rasoro8964.3141ac4"
                                                }, 
                                                {
                                                    "field_id": 20, 
                                                    "field_type": "string", 
                                                    "value": "ru"
                                                }, 
                                                {
                                                    "field_id": 36, 
                                                    "field_type": "i64", 
                                                    "value": 1617095877000
                                                }
                                            ]
                                        }
                                    }, 
                                    {
                                        "field_id": 16, 
                                        "field_type": "struct", 
                                        "value": {
                                            "fields": [
                                                {
                                                    "field_id": 1, 
                                                    "field_type": "i64", 
                                                    "value": 62914560
                                                }, 
                                                {
                                                    "field_id": 2, 
                                                    "field_type": "i64", 
                                                    "value": 1619766000000
                                                }, 
                                                {
                                                    "field_id": 3, 
                                                    "field_type": "i64", 
                                                    "value": 62914560
                                                }, 
                                                {
                                                    "field_id": 4, 
                                                    "field_type": "i32", 
                                                    "value": 0
                                                }, 
                                                {
                                                    "field_id": 14, 
                                                    "field_type": "i64", 
                                                    "value": 1617095877000
                                                }, 
                                                {
                                                    "field_id": 19, 
                                                    "field_type": "i32", 
                                                    "value": 0
                                                }, 
                                                {
                                                    "field_id": 23, 
                                                    "field_type": "i32", 
                                                    "value": 0
                                                }
                                            ]
                                        }
                                    }, 
                                    {
                                        "field_id": 17, 
                                        "field_type": "struct", 
                                        "value": {
                                            "fields": [
                                                {
                                                    "field_id": 1, 
                                                    "field_type": "i64", 
                                                    "value": 1617096413401
                                                }, 
                                                {
                                                    "field_id": 2, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 3, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 5, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 6, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 7, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 8, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 11, 
                                                    "field_type": "bool", 
                                                    "value": true
                                                }
                                            ]
                                        }
                                    }, 
                                    {
                                        "field_id": 19, 
                                        "field_type": "string", 
                                        "value": "https://www.evernote.com/shard/s408/user/225287449/photo"
                                    }, 
                                    {
                                        "field_id": 21, 
                                        "field_type": "i32", 
                                        "value": 1
                                    }, 
                                    {
                                        "field_id": 22, 
                                        "field_type": "struct", 
                                        "value": {
                                            "fields": [
                                                {
                                                    "field_id": 1, 
                                                    "field_type": "i32", 
                                                    "value": 50
                                                }, 
                                                {
                                                    "field_id": 2, 
                                                    "field_type": "i64", 
                                                    "value": 26214400
                                                }, 
                                                {
                                                    "field_id": 3, 
                                                    "field_type": "i64", 
                                                    "value": 26214400
                                                }, 
                                                {
                                                    "field_id": 4, 
                                                    "field_type": "i32", 
                                                    "value": 100
                                                }, 
                                                {
                                                    "field_id": 5, 
                                                    "field_type": "i64", 
                                                    "value": 62914560
                                                }, 
                                                {
                                                    "field_id": 6, 
                                                    "field_type": "i32", 
                                                    "value": 100000
                                                }, 
                                                {
                                                    "field_id": 7, 
                                                    "field_type": "i32", 
                                                    "value": 250
                                                }, 
                                                {
                                                    "field_id": 8, 
                                                    "field_type": "i32", 
                                                    "value": 100000
                                                }, 
                                                {
                                                    "field_id": 9, 
                                                    "field_type": "i32", 
                                                    "value": 100
                                                }, 
                                                {
                                                    "field_id": 10, 
                                                    "field_type": "i32", 
                                                    "value": 100
                                                }, 
                                                {
                                                    "field_id": 11, 
                                                    "field_type": "i32", 
                                                    "value": 1000
                                                }, 
                                                {
                                                    "field_id": 12, 
                                                    "field_type": "i32", 
                                                    "value": 2
                                                }, 
                                                {
                                                    "field_id": 13, 
                                                    "field_type": "i32", 
                                                    "value": 2
                                                }, 
                                                {
                                                    "field_id": 14, 
                                                    "field_type": "i32", 
                                                    "value": 0
                                                }
                                            ]
                                        }
                                    }, 
                                    {
                                        "field_id": 23, 
                                        "field_type": "struct", 
                                        "value": {
                                            "fields": [
                                                {
                                                    "field_id": 1, 
                                                    "field_type": "i64", 
                                                    "value": 1617096413401
                                                }, 
                                                {
                                                    "field_id": 2, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 3, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 5, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 6, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 7, 
                                                    "field_type": "set", 
                                                    "value": {
                                                        "values": [
                                                            2, 
                                                            3
                                                        ], 
                                                        "etype": "i32"
                                                    }
                                                }, 
                                                {
                                                    "field_id": 9, 
                                                    "field_type": "i64", 
                                                    "value": 1648632413401
                                                }, 
                                                {
                                                    "field_id": 10, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }
                                            ]
                                        }
                                    }, 
                                    {
                                        "field_id": 24, 
                                        "field_type": "struct", 
                                        "value": {
                                            "fields": [
                                                {
                                                    "field_id": 1, 
                                                    "field_type": "bool", 
                                                    "value": true
                                                }, 
                                                {
                                                    "field_id": 2, 
                                                    "field_type": "bool", 
                                                    "value": false
                                                }, 
                                                {
                                                    "field_id": 3, 
                                                    "field_type": "i64", 
                                                    "value": 1617095877000
                                                }
                                            ]
                                        }
                                    }, 
                                    {
                                        "field_id": 25, 
                                        "field_type": "bool", 
                                        "value": true
                                    }
                                ]
                            }
                        }, 
                        {
                            "field_id": 6, 
                            "field_type": "string", 
                            "value": "https://www.evernote.com/shard/s408/notestore"
                        }, 
                        {
                            "field_id": 7, 
                            "field_type": "string", 
                            "value": "https://www.evernote.com/shard/s408/"
                        }, 
                        {
                            "field_id": 10, 
                            "field_type": "struct", 
                            "value": {
                                "fields": [
                                    {
                                        "field_id": 1, 
                                        "field_type": "string", 
                                        "value": "https://www.evernote.com/shard/s408/notestore"
                                    }, 
                                    {
                                        "field_id": 2, 
                                        "field_type": "string", 
                                        "value": "https://www.evernote.com/shard/s408/"
                                    }, 
                                    {
                                        "field_id": 3, 
                                        "field_type": "string", 
                                        "value": "https://www.evernote.com/shard/s408/edam/user"
                                    }, 
                                    {
                                        "field_id": 4, 
                                        "field_type": "string", 
                                        "value": "https://www.evernote.com/shard/s408/utility"
                                    }, 
                                    {
                                        "field_id": 5, 
                                        "field_type": "string", 
                                        "value": "https://www.evernote.com/shard/s408/messagestore"
                                    }, 
                                    {
                                        "field_id": 6, 
                                        "field_type": "string", 
                                        "value": "wss://ws.evernote.com/shard/s408/id"
                                    }, 
                                    {
                                        "field_id": 7, 
                                        "field_type": "string", 
                                        "value": "https://www.evernote.com/shard/s408/communicationengine"
                                    }, 
                                    {
                                        "field_id": 8, 
                                        "field_type": "string", 
                                        "value": "https://dashboard.svc.www.evernote.com/v1/main.html#?v=dashboard"
                                    }, 
                                    {
                                        "field_id": 9, 
                                        "field_type": "string", 
                                        "value": "https://dashboard.svc.www.evernote.com/v1/main.html#?v=space-directory"
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        ]
    }, 
    "proto": "binary", 
    "header": null, 
    "seqid": 0
}

对 optional required 的支持问题

struct StructA {
  1: required string s;
}

struct StructB {
  1: optional StructA aa;
  2: required StructA ab;
}

这种的结构体解析是如何支持的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.