JDK-8252051 : Make mlvmJvmtiUtils strncpy uses GCC 10.x friendly
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-08-19
  • Updated: 2022-09-09
  • Resolved: 2020-08-20
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 JDK 15 JDK 16
11.0.14Fixed 13.0.13Fixed 15.0.9Fixed 16 b13Fixed
Related Reports
Relates :  
Relates :  
Description
gcc 10.2 is producing a warning for mlvmJmvtiUtils.cpp:

In file included from test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/share/libIndyRedefineClass.cpp:31:
test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp:100:12: error: 'char* strncpy(char*, const char*, size_t)' specified bound 256 equals destination size [-Werror=stringop-truncation]
  100 |     strncpy(mn->classSig, szSignature, sizeof(mn->classSig));
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

It seems like gcc is not smart enough to realize that the strncpy on the previous line (mn->methodName) cannot modify szSignature.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk13u-dev/pull/400 Date: 2022-09-09 09:34:48 +0000
09-09-2022

Fix request (15u, 13u) low-risk necessary fix for gcc10. Works fine to me.
09-09-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk15u-dev/pull/270 Date: 2022-09-06 09:08:41 +0000
06-09-2022

Fix Request (11u) On behalf of Joshua Cao <joshcao@amazon.com>. Simple patch that guarantees properly null-terminated string and eliminates a compiler warning. Removes workaround that suppressed the warning. Reviewed by phh.
19-10-2021

URL: https://hg.openjdk.java.net/jdk/jdk/rev/4ac656b90253 User: mikael Date: 2020-08-20 18:10:13 +0000
20-08-2020