JDK-8314114 : Fix -Wconversion warnings in os code, primarily linux
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-08-10
  • Updated: 2024-12-24
  • Resolved: 2023-08-15
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.
JDK 22
22 b11Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Fix Wconversion warnings coming from these files:
37 /src/hotspot/os/linux/os_linux.cpp
6 /src/hotspot/os/posix/os_posix.cpp
5 /src/hotspot/os/linux/attachListener_linux.cpp
4 /src/hotspot/os/linux/os_perf_linux.cpp
2 /src/hotspot/os/posix/signals_posix.cpp
1 /src/hotspot/os/linux/waitBarrier_linux.cpp
1 /src/hotspot/os/linux/systemMemoryBarrier_linux.cpp
1 /src/hotspot/os/linux/cgroupSubsystem_linux.cpp

Comments
Thanks Coleen, will get that too...
13-12-2024

Might need to backport this one too: JDK-8313905
13-12-2024

We have identified that, this issue fixes one of the integer overflow issue. For example, In the function os::compare_file_modified_times() of BSD and Linux (open/src/hotspot/os/bsd/os_bsd.cpp or open/src/hotspot/os/linux/os_linux.cpp), the result of the subtract 64 bit value "tv_sec" between 2 files is assigned to 32 bit integer variable "diff". As a result, it potentially cause integer overflow and returning incorrect result. Especially after the year of 2038, the risk is much more obvious since tv_sec become larger than the maximum value of signed int 32 value. Even, if someone sets the timestamp that has enough large value to cause the overflow it may happen the same problem. Code before the fix, int os::compare_file_modified_times(const char* file1, const char* file2) { struct timespec filetime1 = get_mtime(file1); struct timespec filetime2 = get_mtime(file2); int diff = filetime1.tv_sec - filetime2.tv_sec; //<-- the subtract result of 64bit tv_sec into the 32bit int variable if (diff == 0) { return filetime1.tv_nsec - filetime2.tv_nsec; } return diff; } Modifying this as bug and removing cleanup label
13-12-2024

Changeset: 9ded8682 Author: Coleen Phillimore <coleenp@openjdk.org> Date: 2023-08-15 11:05:31 +0000 URL: https://git.openjdk.org/jdk/commit/9ded86821b01d6d790850e9b49eedfc597c0c9a2
15-08-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15229 Date: 2023-08-10 15:22:07 +0000
10-08-2023