Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASAN][upstream][25][clang]dict.cpp:148:15: runtime error: call to function Type::uhash(Type const*) through pointer to incorrect function type 'int (*)(const void *)' #157

Open
sendaoYan opened this issue Dec 25, 2024 · 3 comments
Assignees

Comments

@sendaoYan
Copy link
Collaborator

Configure 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 --with-extra-cflags=-shared-libasan --with-extra-cxxflags=-shared-libasan --with-extra-ldflags=-shared-libasan  --enable-asan --enable-ubsan --enable-lsan --with-toolchain-type=clang --with-toolchain-path=~/software/acc/x86_64/bin

Standalone command:

/home/yansendao/git/jdk-asan-clang/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

result:

src/hotspot/share/libadt/dict.cpp:148:15: runtime error: call to function Type::uhash(Type const*) through pointer to incorrect function type 'int (*)(const void *)'
/home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:419: note: Type::uhash(Type const*) defined here
    #0 0x7f1adb10762d in Dict::Insert(void*, void*, bool) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/libadt/dict.cpp:148:15
    #1 0x7f1addec39bb in Type::hashcons() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:741:29
    #2 0x7f1addec476e in Type::Initialize_shared(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:448:13
    #3 0x7f1addecbd97 in Type::Initialize(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:723:5
    #4 0x7f1ada8bf8e3 in CompileWrapper::CompileWrapper(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/compile.cpp:497:3
    #5 0x7f1ada8d023c in Compile::Compile(ciEnv*, TypeFunc const* (*)(), unsigned char*, char const*, int, bool, bool, DirectiveSet*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/compile.cpp:968:18
    #6 0x7f1add1d3ca9 in OptoRuntime::generate_stub(ciEnv*, TypeFunc const* (*)(), unsigned char*, char const*, int, bool, bool) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/runtime.cpp:206:11
    #7 0x7f1add1d330f in OptoRuntime::generate(ciEnv*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/runtime.cpp:178:3
    #8 0x7f1ada45f316 in C2Compiler::init_c2_runtime() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/c2compiler.cpp:99:10
    #9 0x7f1ada45f5a0 in C2Compiler::initialize() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/c2compiler.cpp:112:23
    #10 0x7f1ada937b30 in CompileBroker::init_compiler_runtime() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/compiler/compileBroker.cpp:1787:11
    #11 0x7f1ada93951d in CompileBroker::compiler_thread_loop() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/compiler/compileBroker.cpp:1929:8
    #12 0x7f1adbbeec9a in JavaThread::thread_main_inner() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/javaThread.cpp:777:5
    #13 0x7f1adbbeddfd in JavaThread::run() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/javaThread.cpp:762:3
    #14 0x7f1adde6cb1f in Thread::call_run() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/thread.cpp:232:9
    #15 0x7f1adcdf0c12 in thread_native_entry(Thread*) /home/yansendao/git/jdk-asan-clang/src/hotspot/os/linux/os_linux.cpp:860:11
    #16 0x7f1ae3936a0a  (/home/yansendao/software/acc/x86_64/lib64/clang/17/lib/linux/libclang_rt.asan-x86_64.so+0x136a0a)
    #17 0x7f1ae37e73fa in start_thread pthread_create.c
    #18 0x7f1ae363fe82 in clone (/lib64/libc.so.6+0x3de82) (BuildId: 3308b7b1df603240fd3f43dd895bcb2ad87e7eb9)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/hotspot/share/libadt/dict.cpp:148:15 in

configure-command.txt
configure-linux-x86_64-server-fastdebug.log
make-linux-x86_64-server-fastdebug-2.log
buildtools_create_symbols_javac__the.COMPILE_CREATE_SYMBOLS_batch.cmdline.log
make-linux-x86_64-server-fastdebug-1.log.zip

@sendaoYan sendaoYan self-assigned this Dec 25, 2024
@sendaoYan
Copy link
Collaborator Author

Optional solutuon 1:

diff --git a/src/hotspot/share/libadt/dict.cpp b/src/hotspot/share/libadt/dict.cpp
index 0343125018e..8a8e7b4ab78 100644
--- a/src/hotspot/share/libadt/dict.cpp
+++ b/src/hotspot/share/libadt/dict.cpp
@@ -145,7 +145,7 @@ void Dict::doubhash() {
 // an old value is found, it's swapped with the prior key-value pair on the
 // list.  This moves a commonly searched-for value towards the list head.
 void*Dict::Insert(void* key, void* val, bool replace) {
-  uint hash = _hash(key);       // Get hash key
+  uint hash = (uint)_hash(key);       // Get hash key
   uint i = hash & (_size - 1);  // Get hash key, corrected for size
   bucket* b = &_bin[i];
   for (uint j = 0; j < b->_cnt; j++) {
diff --git a/src/hotspot/share/opto/type.cpp b/src/hotspot/share/opto/type.cpp
index 407a4a20a9b..5f5346c594c 100644
--- a/src/hotspot/share/opto/type.cpp
+++ b/src/hotspot/share/opto/type.cpp
@@ -416,8 +416,8 @@ const Type* Type::maybe_remove_speculative(bool include_speculative) const {
 }
 
 //------------------------------hash-------------------------------------------
-int Type::uhash( const Type *const t ) {
-  return (int)t->hash();
+int Type::uhash( const void *const t ) {
+  return (int)(((const Type *const)t)->hash());
 }
 
 #define SMALLINT ((juint)3)  // a value too insignificant to consider widening
diff --git a/src/hotspot/share/opto/type.hpp b/src/hotspot/share/opto/type.hpp
index 2dd702b686b..18c87cd3972 100644
--- a/src/hotspot/share/opto/type.hpp
+++ b/src/hotspot/share/opto/type.hpp
@@ -156,7 +156,7 @@ class Type {
   static Dict* _shared_type_dict;
   static const TypeInfo _type_info[];
 
-  static int uhash( const Type *const t );
+  static int uhash( const void *const t );
   // Structural equality check.  Assumes that equals() has already compared
   // the _base types and thus knows it can cast 't' appropriately.
   virtual bool eq( const Type *t ) const;

@sendaoYan
Copy link
Collaborator Author

src/hotspot/share/libadt/dict.cpp:205:12: runtime error: call to function Type::uhash(Type const*) through pointer to incorrect function type 'int (*)(const void *)'
/home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:419: note: Type::uhash(Type const*) defined here
    #0 0x7f7e1bd0825f in Dict::operator[](void const*) const /home/yansendao/git/jdk-asan-clang/src/hotspot/share/libadt/dict.cpp:205:12
    #1 0x7f7e1eac3c22 in Type::hashcons() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:761:3
    #2 0x7f7e1eac477f in Type::Initialize_shared(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:449:13
    #3 0x7f7e1eacbd97 in Type::Initialize(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:723:5
    #4 0x7f7e1b4bf8e3 in CompileWrapper::CompileWrapper(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/compile.cpp:497:3
    #5 0x7f7e1b4d023c in Compile::Compile(ciEnv*, TypeFunc const* (*)(), unsigned char*, char const*, int, bool, bool, DirectiveSet*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/compile.cpp:968:18
    #6 0x7f7e1ddd3ca9 in OptoRuntime::generate_stub(ciEnv*, TypeFunc const* (*)(), unsigned char*, char const*, int, bool, bool) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/runtime.cpp:206:11
    #7 0x7f7e1ddd330f in OptoRuntime::generate(ciEnv*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/runtime.cpp:178:3
    #8 0x7f7e1b05f316 in C2Compiler::init_c2_runtime() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/c2compiler.cpp:99:10
    #9 0x7f7e1b05f5a0 in C2Compiler::initialize() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/c2compiler.cpp:112:23
    #10 0x7f7e1b537b30 in CompileBroker::init_compiler_runtime() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/compiler/compileBroker.cpp:1787:11
    #11 0x7f7e1b53951d in CompileBroker::compiler_thread_loop() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/compiler/compileBroker.cpp:1929:8
    #12 0x7f7e1c7eec9a in JavaThread::thread_main_inner() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/javaThread.cpp:777:5
    #13 0x7f7e1c7eddfd in JavaThread::run() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/javaThread.cpp:762:3
    #14 0x7f7e1ea6cb1f in Thread::call_run() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/thread.cpp:232:9
    #15 0x7f7e1d9f0c12 in thread_native_entry(Thread*) /home/yansendao/git/jdk-asan-clang/src/hotspot/os/linux/os_linux.cpp:860:11
    #16 0x7f7e24536a0a  (/home/yansendao/software/acc/x86_64/lib64/clang/17/lib/linux/libclang_rt.asan-x86_64.so+0x136a0a)
    #17 0x7f7e2504c3fa in start_thread pthread_create.c
    #18 0x7f7e24261e82 in clone (/lib64/libc.so.6+0x3de82) (BuildId: 3308b7b1df603240fd3f43dd895bcb2ad87e7eb9)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/hotspot/share/libadt/dict.cpp:205:12 in

@sendaoYan
Copy link
Collaborator Author

src/hotspot/share/libadt/dict.cpp:126:12: runtime error: call to function Type::uhash(Type const*) through pointer to incorrect function type 'int (*)(const void *)'
/home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:419: note: Type::uhash(Type const*) defined here
    #0 0x7ff63b906985 in Dict::doubhash() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/libadt/dict.cpp:126:12
    #1 0x7ff63b907003 in Dict::Insert(void*, void*, bool) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/libadt/dict.cpp:164:5
    #2 0x7ff63e6c3c51 in Type::hashcons() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:763:9
    #3 0x7ff63e6c5fb8 in Type::Initialize_shared(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:601:25
    #4 0x7ff63e6cbd97 in Type::Initialize(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/type.cpp:723:5
    #5 0x7ff63b0bf8e3 in CompileWrapper::CompileWrapper(Compile*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/compile.cpp:497:3
    #6 0x7ff63b0d023c in Compile::Compile(ciEnv*, TypeFunc const* (*)(), unsigned char*, char const*, int, bool, bool, DirectiveSet*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/compile.cpp:968:18
    #7 0x7ff63d9d3ca9 in OptoRuntime::generate_stub(ciEnv*, TypeFunc const* (*)(), unsigned char*, char const*, int, bool, bool) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/runtime.cpp:206:11
    #8 0x7ff63d9d330f in OptoRuntime::generate(ciEnv*) /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/runtime.cpp:178:3
    #9 0x7ff63ac5f316 in C2Compiler::init_c2_runtime() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/c2compiler.cpp:99:10
    #10 0x7ff63ac5f5a0 in C2Compiler::initialize() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/opto/c2compiler.cpp:112:23
    #11 0x7ff63b137b30 in CompileBroker::init_compiler_runtime() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/compiler/compileBroker.cpp:1787:11
    #12 0x7ff63b13951d in CompileBroker::compiler_thread_loop() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/compiler/compileBroker.cpp:1929:8
    #13 0x7ff63c3eec9a in JavaThread::thread_main_inner() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/javaThread.cpp:777:5
    #14 0x7ff63c3eddfd in JavaThread::run() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/javaThread.cpp:762:3
    #15 0x7ff63e66cb1f in Thread::call_run() /home/yansendao/git/jdk-asan-clang/src/hotspot/share/runtime/thread.cpp:232:9
    #16 0x7ff63d5f0c12 in thread_native_entry(Thread*) /home/yansendao/git/jdk-asan-clang/src/hotspot/os/linux/os_linux.cpp:860:11
    #17 0x7ff644136a0a  (/home/yansendao/software/acc/x86_64/lib64/clang/17/lib/linux/libclang_rt.asan-x86_64.so+0x136a0a)
    #18 0x7ff644c683fa in start_thread pthread_create.c
    #19 0x7ff643e61e82 in clone (/lib64/libc.so.6+0x3de82) (BuildId: 3308b7b1df603240fd3f43dd895bcb2ad87e7eb9)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/hotspot/share/libadt/dict.cpp:126:12 in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant