JDK-8307230 : Fix signed overflow issues found with -ftrapv
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2023-05-02
  • Updated: 2024-04-12
  • Resolved: 2023-05-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Description
There are multiple locations in the Hotspot code (only found in C2 so far, so let's start in compiler) with signed overflows which is undefined behavior (compilers could use this undefined behavior for optimizations). We should check our code by configuring with --with-extra-cxx-flags='-ftrapv' and running some extensive testing with it. -ftrapv emits traps for signed additions, subtractions and multiplications. If there is an overflow, we abort.

The affected version is currently set to 21 but should be updated accordingly to the found issues.
Comments
I instrumented a fastdebug OpenJDK build on Linuxx86_64 with the -ftrapv compile flag; when executing JCK/jtreg tests we got a number exit 134 / Abnormal Termination (SIGABRT). So it looks like there are still quite a few overflows (because without -ftrapv we do not get those exit 134). But no additional error output was seen - how did you analyze the -ftrapv related issues ? Unfortunately I did not notice any hserr files (I would have expected that those are generated) ?
12-04-2024

ILW = Undefined behavior with signed additions, subtractions, and/or multiplications, no crash/wrong execution observed, no workaround = MLH = P4
02-05-2023