JDK-8345012 : os::build_agent_function_name potentially wastes a byte when allocating the buffer
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2024-11-26
  • Updated: 2025-04-07
  • Resolved: 2024-12-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.
JDK 24
24 b27Fixed
Related Reports
Causes :  
Relates :  
Description
From the review of JEP 479:

In src/hotspot/os/windows/os_windows.cpp, around line 5863: https://github.com/openjdk/jdk/pull/21744#discussion_r1828969105

"[pre-existing, and can't comment on line 5858 because it's not sufficiently near a change.] The calculation of len is wasting a byte when lib_name is null. The +2 accounts for the terminating NUL and the underscore separator between the sym_name part and the lib_name part. That underscore isn't added when there isn't a lib_name part. I think the simplest fix would be to change name_len to (name_len +1) and +2 to +1 in that calculation. And add some
commentary. 
-----

The same code pattern exists in os_posix.cpp

I opted for a solution where name_len always reflects the actual length of the lib name - otherwise we need to subtract the 1 again when doing the strncat. I also made the need for the underscore explicit.
Comments
Changeset: 3d0d0e62 Branch: master Author: David Holmes <dholmes@openjdk.org> Date: 2024-12-02 20:54:58 +0000 URL: https://git.openjdk.org/jdk/commit/3d0d0e62900653c4e395166a9ac48578b3dbc1f8
02-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22404 Date: 2024-11-27 00:45:00 +0000
27-11-2024