Mark CheckTxInputs [[nodiscard]] (out-param txfee only set if call is successful).
Avoid use of uninitialised memory (UUM) in fuzzing harness coins_view.
Mark CheckTxInputs [[nodiscard]] (out-param txfee only set if call is successful).
Avoid use of uninitialised memory (UUM) in fuzzing harness coins_view.
Quite fascinating that this was introduced when the fuzz test was initially written exactly one year ago on the day in commit https://github.com/bitcoin/bitcoin/commit/f9b22e3bdb54acb2f830b3ebbad47ff17dfb5781#diff-1ef3b6a1936b50f3d5ec4a1786d9e2d63d1a3e1815b103e67f20601995f355b4R245
OSS-Fuzz report: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34611
Apparently uninitialized reads are hard to reproduce and track down. See also:
review ACK 37371268d14ed6d5739af5b65d8bdb38b0e8dda2
23 | @@ -24,7 +24,7 @@ namespace Consensus { 24 | * @param[out] txfee Set to the transaction fee if successful. 25 | * Preconditions: tx.IsCoinBase() is false. 26 | */ 27 | -bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee); 28 | +[[nodiscard]] bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
might be nice to change this to a struct similar to struct MempoolAcceptResult, so that std::optional can be used
Agreed! That would make a nice follow-up PR. Keeping this PR as-is to limit scope.
What's UUM?
Use of uninitialised memory (UUM) :)
The abbreviation is sometimes used in the academic literature (see the MemorySanitizer paper as an example), but after Googling it I now understand it is not used outside of academia AFAICT. Sorry about the unusual abbreviation: I've now updated the OP to make it more clear :)