HomePhabricator

Fix undefined behavior in avalanche.cpp

Description

Fix undefined behavior in avalanche.cpp

Summary:
In the MMIX LCG calculation, the right side calculation underlying type
is signed. This causes the undefined behavior sanitizer to detect a
signed integer overflow.
This diff sets the constants to unsigned long long to enforce the
underlying type to be unsigned and get rid of this error.

Test Plan:
With the UBSAN activated, run

test_bitcoin -t avalanche_tests

Reviewers: #bitcoin_abc, deadalnix, markblundeberg

Reviewed By: #bitcoin_abc, deadalnix, markblundeberg

Subscribers: markblundeberg

Differential Revision: https://reviews.bitcoinabc.org/D3074

Details

Provenance
FabienAuthored on May 20 2019, 11:11
FabienPushed on May 21 2019, 09:25
Reviewer
Restricted Project
Differential Revision
D3074: Fix undefined behavior in avalanche.cpp
Parents
rABCedb02081d31d: Simplify semantics of ChainStateFlushed callback
Branches
Unknown
Tags
Unknown