RFR: JDK-8290822: C2: assert in PhaseIdealLoop::do_unroll() is subject to undefined behavior
Tobias Holenstein
tholenstein at openjdk.org
Thu Feb 16 12:18:24 UTC 2023
The following assert had undefined behavior (UB) because of _signed_ integer underflow/overflow:
assert(stride_con > 0 && ((limit_type->_hi - stride_con) < limit_type->_hi) ||
stride_con < 0 && ((limit_type->_lo - stride_con) > limit_type->_lo),
"sanity");
# Solution
The fix is to check for underflow/overflow (the purpose of the assert) without actually underflowing/overflowing.
-------------
Commit messages:
- assert should check that NO overflow occurs
- JDK-8290822: C2: assert in PhaseIdealLoop::do_unroll() is subject to undefined behavior
Changes: https://git.openjdk.org/jdk/pull/12576/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12576&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8290822
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/12576.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12576/head:pull/12576
PR: https://git.openjdk.org/jdk/pull/12576
More information about the hotspot-compiler-dev
mailing list