Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gagliardetto/binary have some problem #95

Closed
yangyangpig opened this issue Aug 15, 2022 · 2 comments · Fixed by gagliardetto/binary#6
Closed

gagliardetto/binary have some problem #95

yangyangpig opened this issue Aug 15, 2022 · 2 comments · Fixed by gagliardetto/binary#6

Comments

@yangyangpig
Copy link

show code:

mintAccount, err := mintInstance.SolanaClient.RPC.GetAccountInfo(context.Background(), metadataPubkey)
if err != nil {
panic(err)
}
var metdataData *tokenmetadata.Metadata
if err := bin.NewBinDecoder(mintAccount.Value.Data.GetBinary()).Decode(&metdataData); err != nil {
log.Errorf("NewBinDecoder error %+v", err)
return
}


error info:

--- FAIL: TestGetProgramAccounts (35.10s)
panic: runtime error: makeslice: len out of range [recovered]
panic: runtime error: makeslice: len out of range

goroutine 52 [running]:
testing.tRunner.func1.2({0x102576920, 0x1025eb460})
/usr/local/go/src/testing/testing.go:1209 +0x258
testing.tRunner.func1(0x1400068ab60)
/usr/local/go/src/testing/testing.go:1212 +0x284
panic({0x102576920, 0x1025eb460})
/usr/local/go/src/runtime/panic.go:1038 +0x21c
github.com/gagliardetto/binary.readNBytes(0x676e696b00000020, {0x1025f4448, 0x14000665920})
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder.go:273 +0x38
github.com/gagliardetto/binary.(*Decoder).ReadNBytes(...)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder.go:286
github.com/gagliardetto/binary.(*Decoder).ReadRustString(0x14000665920)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder.go:548 +0x74
github.com/gagliardetto/binary.(*Decoder).decodeBin(0x14000665920, {0x1025558c0, 0x14000184048, 0x16}, 0x0)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder_bin.go:89 +0x10f4
github.com/gagliardetto/binary.(*Decoder).decodeWithOptionBin(0x14000665920, {0x1025558c0, 0x14000184048}, 0x0)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder_bin.go:36 +0x1a8
github.com/gagliardetto/binary.(*Decoder).Decode(0x14000665920, {0x1025558c0, 0x14000184048})
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder.go:121 +0xc4
github.com/gagliardetto/metaplex-go/clients/token-metadata.(*Data).UnmarshalWithDecoder(0x14000184048, 0x14000665920)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/metaplex-go@v0.2.1/clients/token-metadata/accounts.go:113 +0x40
github.com/gagliardetto/binary.(*Decoder).decodeBin(0x14000665920, {0x1025786a0, 0x14000184048, 0x16}, 0x0)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder_bin.go:83 +0x628
github.com/gagliardetto/binary.(*Decoder).decodeWithOptionBin(0x14000665920, {0x1025786a0, 0x14000184048}, 0x0)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder_bin.go:36 +0x1a8
github.com/gagliardetto/binary.(*Decoder).Decode(0x14000665920, {0x1025786a0, 0x14000184048})
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder.go:121 +0xc4
github.com/gagliardetto/metaplex-go/clients/token-metadata.(*Metadata).UnmarshalWithDecoder(0x14000184000, 0x14000665920)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/metaplex-go@v0.2.1/clients/token-metadata/accounts.go:690 +0xdc
github.com/gagliardetto/binary.(*Decoder).decodeBin(0x14000665920, {0x10254eb80, 0x140004c45e0, 0x16}, 0x0)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder_bin.go:83 +0x628
github.com/gagliardetto/binary.(*Decoder).decodeWithOptionBin(0x14000665920, {0x10254eb80, 0x140004c45e0}, 0x0)
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder_bin.go:36 +0x1a8
github.com/gagliardetto/binary.(*Decoder).Decode(0x14000665920, {0x10254eb80, 0x140004c45e0})
/Users/davidliu/go/pkg/mod/github.com/gagliardetto/binary@v0.6.1/decoder.go:121 +0xc4
azeroth.io/northrend/kafu/solana/nft.TestGetProgramAccounts(0x1400068ab60)
/Users/davidliu/company/ttc/northrend-mono/northrend/kafu/solana/nft/mint_test.go:115 +0xea0
testing.tRunner(0x1400068ab60, 0x1025e95c0)
/usr/local/go/src/testing/testing.go:1259 +0xfc
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:1306 +0x328
exit status 2


This question has puzzled me for a long time. Please help me 😊

@riptl
Copy link
Contributor

riptl commented Aug 17, 2022

cc @gagliardetto I'm planning to fix this today. The bug here is that reflect.MakeSlice is called without prior bounds checks. (Bounds checks are only implied as the slice is populated)

@gagliardetto
Copy link
Owner

cc @gagliardetto I'm planning to fix this today. The bug here is that reflect.MakeSlice is called without prior bounds checks. (Bounds checks are only implied as the slice is populated)

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants