Skip to content

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 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

Development

Successfully merging this pull request may close these issues.

1 participant