FactomProject / factomd

Factom Daemon
https://www.factomprotocol.org/
Other
201 stars 92 forks source link

TestDBSigElection nil pointer error #1070

Closed WhoSoup closed 3 years ago

WhoSoup commented 3 years ago

This bug happened consistently in the TestDBSigElection unit test, where it attempted to read from a message's LeaderChainID that was nil. It took me a long time to figure out where the message actually came from, and the source is the election code, pushing an audit server's volunteer message into the process list as a directory block signature message.

This fix is two-fold:

Only the first item is necessary for this to be fixed, the second change is just for consistency.

So what caused this? I'm still not entirely sure. My current working theory is that it could have been a logging change. While debugging, I noticed that if I tried to check a generic message via GetLeaderChainID(), the error would not occur since that function sets the field to be not nil. It is possible that somewhere in the previous code, GetLeaderChainID() was called for logging messages, meaning that all messages would have had the field set.