Skip to content

Conversation

@entropycoset
Copy link

When trying to be a witness, and loading custom genesis where initial_timestamp is far behind, there seems to be an C++ UB
in dgp.recent_slots_filled = ... << missed_blocks
in https://github.com/bitshares/bitshares-core/blob/develop/libraries/chain/db_update.cpp#L68
because we left-shift by more than 126 (or 127, 128) bits there
https://timsong-cpp.github.io/cppwp/n4140/expr.shift#1 for C++14.

I suppose an explanation + abort is better than UB (or than trying to continue with settings the value to 0)

@abitmore
Copy link
Member

abitmore commented Aug 2, 2025

recent_slot_filled is just used to calculate "witness participation rate", see https://github.com/bitshares/bitshares-core/blob/master/libraries/wallet/wallet_api_impl.cpp#L119 (IIRC it is also used in block production). Shifting and dropping the high bits is intended behavior. In my opinion UB on it is not serious at all and should not cause an abortion.

@abitmore
Copy link
Member

abitmore commented Aug 2, 2025

Also see c019f18 for why it was implemented like that.

@entropycoset
Copy link
Author

Then for the approach that sets resulting value to 0 (all bits are shifted away), and prints a warning - this PR: #2825

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants