JDK-8346714 : [ASAN] compressedKlass.cpp reported applying non-zero offset to null pointer
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 25
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-12-20
  • Updated: 2025-01-05
  • Resolved: 2024-12-23
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 25
25 b04Fixed
Related Reports
Relates :  
Description
CompressedKlassPointers::sanity_check_after_initialization() src/hotspot/share/oops/compressedKlass.cpp:104:38 reported runtime error: applying non-zero offset 4294967296 to null pointer by clang17 UndefinedBehaviorSanitizer.

The UndefinedBehaviorSanitizer output:
src/hotspot/share/oops/compressedKlass.cpp:104:38: runtime error: applying non-zero offset 4294967296 to null pointer
    #0 0x7fac1b190eb4 in CompressedKlassPointers::sanity_check_after_initialization() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/oops/compressedKlass.cpp:104:38
    #1 0x7fac1b193333 in CompressedKlassPointers::initialize(unsigned char*, unsigned long) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/oops/compressedKlass.cpp:299:3
    #2 0x7fac1d2d9a0c in Metaspace::global_initialize() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/memory/metaspace.cpp:808:5
    #3 0x7fac1e7443e3 in universe_init() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/memory/universe.cpp:888:3
    #4 0x7fac1c1e9523 in init_globals() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/init.cpp:133:17
    #5 0x7fac1e6a83ba in Threads::create_vm(JavaVMInitArgs*, bool*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/threads.cpp:574:17
    #6 0x7fac1c6bcece in JNI_CreateJavaVM_inner(JavaVM_**, void**, void*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/prims/jni.cpp:3589:12
    #7 0x7fac1c6bcece in JNI_CreateJavaVM /home/yansendao/git/jdk-asan-clang/src/hotspot/share/prims/jni.cpp:3680:14
    #8 0x7fac24a549d1 in InitializeJVM /home/yansendao/git/jdk-asan-clang/src/java.base/share/native/libjli/java.c:1495:9
    #9 0x7fac24a549d1 in JavaMain /home/yansendao/git/jdk-asan-clang/src/java.base/share/native/libjli/java.c:494:10
    #10 0x7fac24a61910 in ThreadJavaMain /home/yansendao/git/jdk-asan-clang/src/java.base/unix/native/libjli/java_md.c:649:29
    #11 0x7fac23f36a0a  (/home/yansendao/software/acc/x86_64/lib64/clang/17/lib/linux/libclang_rt.asan-x86_64.so+0x136a0a)
    #12 0x7fac249e33fa in start_thread pthread_create.c
    #13 0x7fac23c61e82 in clone (/lib64/libc.so.6+0x3de82) (BuildId: 3308b7b1df603240fd3f43dd895bcb2ad87e7eb9)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/hotspot/share/oops/compressedKlass.cpp:104:38 in 

Configure and make command:
export PATH=~/software/acc/`arch`/bin:$PATH ; export LD_LIBRARY_PATH=~/software/acc/`arch`/lib64/clang/17/lib/linux:$LD_LIBRARY_PATH ; export CFLAGS="-shared-libasan" ; export CXXFLAGS=$CFLAGS ; export LDFLAGS=$CFLAGS ; export "CUSTOM_CONFIG=--enable-asan --enable-ubsan --enable-lsan --with-toolchain-type=clang --with-toolchain-path=~/software/acc/`arch`/bin" && export ASAN_OPTIONS="detect_leaks=0,abort_on_error=0,verbosity=3" && export LSAN_OPTIONS=suppressions=$HOME/tone/tone-matrix-compiler/jtreg/asan/leak-suppressions.txt && export UBSAN_OPTIONS="suppressions=$HOME/tone/tone-matrix-compiler/jtreg/asan/suppressions-UndefinedBehavior-clang.txt,print_stacktrace=1"
bash configure --with-jobs=128 --prefix=/home/yansendao/git/jdk-asan-clang/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=23d6f747 --with-zlib=system --enable-ccache --with-native-debug-symbols=external
make images test-image

UndefinedBehaviorSanitizer runtime failure reproduce command:
build/linux-x86_64-server-fastdebug/jdk/bin/javac -J-Djava.io.tmpdir=/home/yansendao/git/jdk-asan-clang/build/linux-x86_64-server-fastdebug/support/javatmp -g -Xlint:all -source 25 -target 25 -implicit:none -Xprefer:source -XDignore.symbol.file=true -encoding ascii -Werror --add-modules jdk.compiler,jdk.jdeps --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED -Xlint:-options -XDmodifiedInputs=/home/yansendao/git/jdk-asan-clang/build/linux-x86_64-server-fastdebug/buildtools/create_symbols_javac/_the.COMPILE_CREATE_SYMBOLS_batch.modfiles.fixed -d /home/yansendao/git/jdk-asan-clang/build/linux-x86_64-server-fastdebug/buildtools/create_symbols_javac @/home/yansendao/git/jdk-asan-clang/build/linux-x86_64-server-fastdebug/buildtools/create_symbols_javac/_the.COMPILE_CREATE_SYMBOLS_batch.filelist

clang version:
clang version 17.0.6 (Alibaba Cloud Compiler 17.0.6.1-24.05.10.alios7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/yansendao/software/acc/x86_64/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/10
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

Comments
Changeset: bffa77bc Branch: master Author: SendaoYan <syan@openjdk.org> Date: 2024-12-23 11:27:12 +0000 URL: https://git.openjdk.org/jdk/commit/bffa77bc04219d3b2fd0898f5e62f324503b2b94
23-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22848 Date: 2024-12-20 12:56:08 +0000
20-12-2024

The _base initial as nullptr in function CompressedKlassPointers::initialize(address addr, size_t len) shows as below. In C/C++, offsetting a null pointer is undefined behavior. address const end = addr + len; if (end <= (address)unscaled_max) { _base = nullptr; _shift = 0;
20-12-2024

Introduced by JDK-8305895
20-12-2024