JDK-8220074 : Clean up GCC 8.3 errors in LittleCMS
  • Type: Sub-task
  • Component: client-libs
  • Sub-Component: 2d
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-03-04
  • Updated: 2021-07-12
  • Resolved: 2019-11-19
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 14
11.0.12Fixed 14 b24Fixed
Description
Few pieces of GCC 8.3 output:

src/java.desktop/share/native/liblcms/cmscgats.c: In function ���GetVal���:
src/java.desktop/share/native/liblcms/cmscgats.c:1021:19: error: ���strncpy��� output may be truncated copying between 255 and 1023 bytes from a string of length 1023 [-Werror=stringop-truncation]
     case SSTRING: strncpy(Buffer, it8->str, max);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ���AllocString���,
    inlined from ���AddToList.constprop��� at src/java.desktop/share/native/liblcms/cmscgats.c:1219:22:
src/java.desktop/share/native/liblcms/cmscgats.c:1146:14: error: ���strncpy��� output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
     if (ptr) strncpy (ptr, str, Size-1);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/java.desktop/share/native/liblcms/cmscgats.c: In function ���AddToList.constprop���:
src/java.desktop/share/native/liblcms/cmscgats.c:1141:46: note: length computed here
     cmsUInt32Number Size = (cmsUInt32Number) strlen(str)+1;
                                              ^~~~~~~~~~~
In function ���AllocString���,
    inlined from ���AddToList.constprop��� at src/java.desktop/share/native/liblcms/cmscgats.c:1250:22:
src/java.desktop/share/native/liblcms/cmscgats.c:1146:14: error: ���strncpy��� output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
     if (ptr) strncpy (ptr, str, Size-1);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
...
In function ���cmsIT8SetSheetType���,
    inlined from ���ParseIT8��� at src/java.desktop/share/native/liblcms/cmscgats.c:2144:41:
src/java.desktop/share/native/liblcms/cmscgats.c:1370:9: error: ���strncpy��� output may be truncated copying 1023 bytes from a string of length 1023 [-Werror=stringop-truncation]
         strncpy(t ->SheetType, Type, MAXSTR-1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...


Comments
jdk11 backport request I would like to have the patch in jdk11 as well, because it is needed for building with gcc9. Backport review was done together with another gcc-9 related fix (8232084) here : https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2021-May/006176.html .
14-05-2021

URL: https://hg.openjdk.java.net/jdk/jdk/rev/6645186a5a31 User: ysuenaga Date: 2019-11-19 04:33:50 +0000
19-11-2019

I also agree with disabling warnings.
12-11-2019

I agree with Mikael. We can disable these warnings. Someone is working for this issue? If doesn't, I can take it. I think we can fix as below: diff -r 0c671290204c make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Thu Oct 31 04:17:41 2019 +0100 +++ b/make/lib/Awt2dLibraries.gmk Thu Oct 31 16:44:43 2019 +0900 @@ -371,6 +371,16 @@ BUILD_LIBLCMS_INCLUDE_FILES := endif +BUILD_LIBLCMS_DISABLE_WARNINGS_gcc := format-nonliteral type-limits \ + misleading-indentation undef unused-function +ifeq ($(TOOLCHAIN_TYPE), gcc) + GCC_MAJOR_VER := $(shell $(ECHO) $(CC_VERSION_NUMBER) | $(CUT) -d . -f 1) + GCC_8_OR_LATER := $(shell [ $(GCC_MAJOR_VER) -ge 8 ] && echo true) + ifeq ($(GCC_8_OR_LATER), true) + BUILD_LIBLCMS_DISABLE_WARNINGS_gcc += stringop-truncation + endif +endif + $(eval $(call SetupJdkLibrary, BUILD_LIBLCMS, \ NAME := lcms, \ INCLUDE_FILES := $(BUILD_LIBLCMS_INCLUDE_FILES), \ @@ -382,8 +392,7 @@ common/awt/debug \ libawt/java2d, \ HEADERS_FROM_SRC := $(LIBLCMS_HEADERS_FROM_SRC), \ - DISABLED_WARNINGS_gcc := format-nonliteral type-limits \ - misleading-indentation undef unused-function, \ + DISABLED_WARNINGS_gcc := $(BUILD_LIBLCMS_DISABLE_WARNINGS_gcc) \ DISABLED_WARNINGS_clang := tautological-compare format-nonliteral undef, \ DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \ DISABLED_WARNINGS_microsoft := 4819, \
31-10-2019

Given that this is a 3rd party library the preferred way to address this is to notify upstream and disable the warning until there's a new release available with the necessary fixes.
20-05-2019