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

fix: panic in MarshalToSizedBuffer on optional fields #150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lklimek
Copy link

@lklimek lklimek commented Feb 17, 2025

When using protoc-gen-gogofaster with proto3 optional fields, I get panic in MarshalToSizedBuffer:

panic: runtime error: invalid memory address or nil pointer dereference

Full proto3 message definition can be found here, important part:

message ValidatorParams {
  optional uint64 voting_power_threshold = 2;  //[(gogoproto.nullable) = true]
}

Solution

Added check if message to marshal is nil.

Logs

github.com/dashpay/tenderdash/proto/tendermint/types.(*ValidatorParams_VotingPowerThreshold).MarshalToSizedBuffer(...)
        tenderdash/proto/tendermint/types/params.pb.go:1323
github.com/dashpay/tenderdash/proto/tendermint/types.(*ValidatorParams_VotingPowerThreshold).MarshalTo(0x0, {0xc0004a6960, 0xc0004a6966?, 0x33})
        tenderdash/proto/tendermint/types/params.pb.go:1318 +0x8e
github.com/dashpay/tenderdash/proto/tendermint/types.(*ValidatorParams).MarshalToSizedBuffer(0xc0006819e0, {0xc0004a6930, 0x30, 0x63})
        tenderdash/proto/tendermint/types/params.pb.go:1299 +0x126
github.com/dashpay/tenderdash/proto/tendermint/types.(*ConsensusParams).MarshalToSizedBuffer(0xc000147e20, {0xc0004a6930, 0x61, 0x63})
        tenderdash/proto/tendermint/types/params.pb.go:1164 +0x5b5
github.com/dashpay/tenderdash/proto/tendermint/state.(*ConsensusParamsInfo).MarshalToSizedBuffer(0xc000147e20, {0xc0004a6930, 0x63, 0x63})
        tenderdash/proto/tendermint/state/types.pb.go:579 +0xea

@lklimek lklimek requested a review from a team as a code owner February 17, 2025 16:05
@lklimek lklimek marked this pull request as draft February 17, 2025 16:07
@lklimek lklimek marked this pull request as ready for review February 17, 2025 16:20
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 this pull request may close these issues.

1 participant