RFR: 8355711: Fix incorrect overflow check in RawBytecodeStream::raw_next [v2]

Dean Long dlong at openjdk.org
Mon Apr 28 20:10:48 UTC 2025


On Mon, 28 Apr 2025 15:50:00 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> Hi,
>> 
>> This fixes a typical wrong overflow check. `_bci` and `_next_bci` are both `int`, so any overflow is undefined, therefore an optimizing C++ compiler is allowed to remove this check. When looking at the x64 assembly for this, I could not find the check, so I guess that it was actually removed as well.
>
> Johan Sjölen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix indentation

src/hotspot/share/interpreter/bytecodeStream.hpp line 139:

> 137:              && code != Bytecodes::_lookupswitch, "can't be special bytecode");
> 138:       _is_wide = false;
> 139:       if (INT_MAX - len <= _next_bci) { // Check for integer overflow

I don't see how we can ever hit this case, given the `_bci <= _end_bci - len` test above.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24920#discussion_r2064465510


More information about the hotspot-runtime-dev mailing list