RFR: 8345016: [ASAN] java.c false positive ‘%s’ directive argument is null [-Werror=format-truncation=] [v2]

SendaoYan syan at openjdk.org
Mon Dec 16 12:47:13 UTC 2024


On Wed, 4 Dec 2024 16:04:01 GMT, SendaoYan <syan at openjdk.org> wrote:

>> Hi all,
>> The file src/java.base/share/native/libjli/java.c generate  compile warning by gcc14 with gcc options `-fsanitize=undefined -O2`, and make jdk build error when configure with option `--enable-ubsan`. So I think it's necessory to  make gcc quiet and make jdk build normally with configure option `--enable-ubsan`.
>> 
>> This PR add `NULL` check for `s` after call `s = JLI_WildcardExpandClasspath(s);` to make gcc quiet. There is another solution to disable the compile warning seen as below, but it will disable the compile warning of java.c. So I use the first solution.
>> 
>> 
>> 
>> diff --git a/make/modules/java.base/lib/CoreLibraries.gmk b/make/modules/java.base/lib/CoreLibraries.gmk
>> index 61ac495968a..5bc83cf0978 100644
>> --- a/make/modules/java.base/lib/CoreLibraries.gmk
>> +++ b/make/modules/java.base/lib/CoreLibraries.gmk
>> @@ -178,6 +178,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \
>>      OPTIMIZATION := HIGH, \
>>      CFLAGS := $(LIBJLI_CFLAGS) $(LIBZ_CFLAGS), \
>>      DISABLED_WARNINGS_gcc := unused-function unused-variable, \
>> +    DISABLED_WARNINGS_gcc_java.c := format-truncation, \
>>      DISABLED_WARNINGS_clang := deprecated-non-prototype format-nonliteral \
>>          unused-function, \
>>      DISABLED_WARNINGS_clang_java_md_macosx.m := unused-variable, \
>
> SendaoYan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix compile warning C4068: unknown pragma 'GCC' on windows

Thanks Jaikiran.

If I add `NULL` check after call `s = JLI_WildcardExpandClasspath(s);`, the gcc14.x also became quiet. I think it's more reasonable change. Just like below


    if (s == NULL)
        return;
    s = JLI_WildcardExpandClasspath(s);
    if (s == NULL)
        return;

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22546#issuecomment-2545523734


More information about the core-libs-dev mailing list