tendermint: Something wrong with cdc.UnmarshalBinaryBare?

Tendermint version (use tendermint version or git rev-parse --verify HEAD if installed from source):

ABCI app (name for built-in, URL for self-written if it’s publicly available):

Environment:

  • OS (e.g. from /etc/os-release):
  • Install tools:
  • Others:

What happened: I was trying to write a test case, but found mockApp trigger a nil-pointer exception func (mock *mockProxyApp) DeliverTx(tx []byte) abci.ResponseDeliverTx { r := mock.abciResponses.DeliverTx[mock.txCount] mock.txCount++ return *r //this line nil-pointer } then I found it indeed is a nil pointer, then I add some code in ApplyBlock:

bytes:=cdc.MustMarshalBinaryBare(abciResponses)
newabciResponses := new(ABCIResponses)
err = cdc.UnmarshalBinaryBare(bytes, newabciResponses)
if err != nil {
	// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
	fmt.Sprintf(`LoadABCIResponses: Data has been corrupted or its spec has
            changed: %v\n`, err)
}

// Save the results before we commit.
saveABCIResponses(blockExec.db, block.Height, abciResponses)

I set a breakpoint after UnmarshalBinaryBare and found the newabciResponses contains nil DeliverTxResponse, while abciResponse contains not nil DeliverTxResponse. The fields in DeliverTxResponse returned is all 0 or empty bytes, but we should not lose the structure, Unmarshal return a nil-pointer.

What you expected to happen:

Have you tried the latest version: yes/no

How to reproduce it (as minimally and precisely as possible):

Logs (paste a small part showing an error (< 10 lines) or link a pastebin, gist, etc. containing more of the log file):

Config (you can paste only the changes you’ve made):

node command runtime flags:

/dump_consensus_state output for consensus bugs

Anything else we need to know:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

Allow me to do it. I can fix it in #3067 just by the way.

This issue can be closed as now there is a safety check on save to remove nil values. I ran into this when migrating to protobuf but now it should be fixed