JDK-8218935 : Make jfr strncpy uses GCC 8.x friendly
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: jfr
  • Affected Version: 13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-02-13
  • Updated: 2020-04-27
  • Resolved: 2019-02-14
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 11 JDK 13 Other
11.0.6Fixed 13 b09Fixed openjdk8u262Fixed
Related Reports
Relates :  
Relates :  
Description
 GCC 8.2 is producing warnings like this:

In function 'char* copy_path(const char*)',
   inlined from 'void JfrChunkState::set_path(const char*)' at src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:115:22:
src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:103:10: error: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
  strncpy(new_path, path, path_len);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

Basically, gcc is pointing out that the resulting string is not going to be terminated. This is fine from a functional perspective, because in all cases the very next thing we do is add the necessary nul termination, but having strncpy produce a nul terminated string has the benefit of not having to terminate it explicitly, and, of course, silence the warnings.

Comments
Replacing jdk8u-fix-request with link to JDK-8239140
17-02-2020

RFC: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-January/011063.html
30-01-2020

Fix Request (11u): This backport is useful for it's content and also makes for a somewhat cleaner backport of JDK-8217362, which had a RFR where it was discussed to have this included [1]. The patch applies cleanly. Tier one tests ran successfully for me with this patch applied. [1] http://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-September/001812.html
04-09-2019