Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8345016

[ASAN] java.c reported ‘%s’ directive argument is null [-Werror=format-truncation=]

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 21, 24
    • core-libs
    • None
    • b06
    • generic
    • linux

      java.c false positive ‘%s’ directive argument is null [-Werror=format-truncation=] by gcc14 with gcc options -fsanitize=undefined -O2.

      Configure command:
      bash configure --with-jobs=128 --prefix=/home/yansendao/git/jdk-asan-gcc/install-fastdebug --verbose --with-debug-level=fastdebug --enable-unlimited-crypto --with-vendor-name=yansendao --with-vendor-url=https://github.com/sendaoYan --with-vendor-bug-url=mailto:yansendao.ysd@alibaba-inc.com --with-vendor-vm-bug-url=mailto:yansendao.ysd@alibaba-inc.com --with-jvm-variants=server --with-boot-jdk=/home/yansendao/software/jdk/24/jdk-repo-binary --with-gtest=/home/yansendao/git/googletest-v1.14.x --with-jtreg=/home/yansendao/software/jdk/jtreg-7.4 --with-jmh=build/jmh/jars --with-version-opt=367c3041 --with-zlib=system --enable-ccache --with-native-debug-symbols=external --with-toolchain-type=gcc --with-toolchain-path=~/software/gcc/gcc-14.2.0-binary/bin --enable-asan --enable-ubsan --enable-lsan

      Make command:
      make all

      The full compile command is:
      gcc -MMD -MF build/linux-x86_64-server-fastdebug/support/native/java.base/libjli/java.d.tmp -fpch-preprocess -fvisibility=hidden -pipe -fstack-protector -DLIBC=gnu -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DLINUX -DDEBUG -g -gdwarf-4 -std=c11 -fno-strict-aliasing -Wall -Wextra -Wformat=2 -Wpointer-arith -Wreturn-type -Wsign-compare -Wtrampolines -Wundef -Wunused-const-variable=1 -Wunused-function -Wunused-result -Wunused-value -m64 -D_LITTLE_ENDIAN '-DARCH="amd64"' -Damd64 -D_LP64=1 -fno-omit-frame-pointer -fno-lifetime-dse -fPIC -fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER --param asan-use-after-return=0 -fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER -fsanitize=leak -fno-omit-frame-pointer -DLEAK_SANITIZER -Isrc/java.base/unix/native/libjli -Isrc/java.base/share/native/libjli -Ibuild/linux-x86_64-server-fastdebug/support/headers/java.base -Isrc/hotspot/share/include -Isrc/hotspot/os/posix/include -Ibuild/linux-x86_64-server-fastdebug/support/modules_include/java.base -Isrc/java.base/unix/native/include -Isrc/java.base/share/native/include -g -gdwarf-4 -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Werror -O2 -D_FORTIFY_SOURCE=2 -c -o build/linux-x86_64-server-fastdebug/support/native/java.base/libjli/java.o src/java.base/share/native/libjli/java.c -frandom-seed=java.c

      Gcc report:
      src/java.base/share/native/libjli/java.c: In function ‘SetClassPath.part.0’:
      src/java.base/share/native/libjli/java.c:1022:28: error: ‘%s’ directive argument is null [-Werror=format-truncation=]
       1022 | snprintf(def, defSize, format, s);
            | ^~~~~~
      cc1: all warnings being treated as errors

            syan Sendao Yan
            syan Sendao Yan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: