Although unsigned integer overflow is not undefined behavior, it’s preferable to eliminate the need for an UBSan suppression for it.
This is an alternative to #29541.
script/interpreter.cpp
#29543
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For detailed information about the code coverage, see the test coverage report.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | sipa |
Concept ACK | hernanmarino |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Although unsigned integer overflow is not undefined behavior, it's
preferable to eliminate the need for a UBSan suppression for it.
Needs rebase.
Rebased.
But see also the discussion in #29541. I would prefer narrowing the suppression to as little as possible…
Anything in your mind without growing the diff up to 10+ lines?
but without touching the ancient code.
I still believe that the suggested diff is reviewable.
ACK 754ba687ccc16bb609c9b22bc2d3bbf0a82d5bce
This is consensus-critical code, so I’ve carefully verified that this change does not modify behavior:
stacktop()
and altstacktop()
use either a small negative integer literal (between -6
and -1
) as argument, or small int
values between -42 and -1 (in the OP_CHECKMULTISIG code).int
and 32-bit or 64-bit size_t
.stack.size()
) is always an unsigned type of rank at least as high as int
’s, which is sized.int
and size_t
will involve an conversion to size_t
of both inputs; for negative int
s i
, that conversion is 2^N + i
, with N the size of size_t
(32 or 64).stack.size() + (i)
is therefor equal to 2^N + stack.size() + i
, which due to the modular nature of the unsigned type size_t
, equals (stack.size() + i) mod 2^N
.(i)
is a small strictly negative int, and thus (-i)
is a small strictly positive int.size_t
happens, and thus stack.size() - (-i)
is (stack.size() + i) mod 2^N
.🐙 This pull request conflicts with the target branch and needs rebase.
⌛ There hasn’t been much activity lately and the patch still needs rebase. What is the status here?