dragonwell-project / dragonwell21

GNU General Public License v2.0
70 stars 20 forks source link

[ASAN][upstream]memory leak in CompactHashtableWriter::CompactHashtableWriter(int, CompactHashtableStats*) src/hotspot/share/classfile/compactHashtable.cpp:54 #137

Open sendaoYan opened 1 day ago

sendaoYan commented 1 day ago

build command:

export "CUSTOM_CONFIG=--enable-asan --enable-ubsan --enable-lsan" && export ASAN_OPTIONS="detect_leaks=1" && export LSAN_OPTIONS=suppressions=$HOME/tone/tone-matrix-compiler/jtreg/asan/leak-suppressions.txt
bash configure --with-jobs=128 --prefix=/home/yansendao/git/jdk/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=8a2a75e5 --with-zlib=system --enable-ccache --with-native-debug-symbols=external    --enable-asan --enable-ubsan --enable-lsan
time make all

java memory leak replay command:

/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/bin/java -Xshare:dump -XX:SharedClassListFile=/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/link_opt/classlist.interim -XX:SharedArchiveFile=/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/link_opt/classlist.jsa -Xmx128M -Xms128M

result:

==1759757==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4465 byte(s) in 235 object(s) allocated from:
    #0 0x7f363fcb0667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667)
    #1 0x7f3628362ce7 in os::malloc(unsigned long, MemTag, NativeCallStack const&) (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x142cbce7)
    #2 0x7f36231d267a in AllocateHeap(unsigned long, MemTag, AllocFailStrategy::AllocFailEnum) (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0xf13b67a)
    #3 0x7f3624a037aa in CompactHashtableWriter::CompactHashtableWriter(int, CompactHashtableStats*) (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x1096c7aa)
    #4 0x7f36297c8ff1 in SymbolTable::write_to_archive(GrowableArray<Symbol*>*) (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x15731ff1)
    #5 0x7f3627e0f37e in VM_PopulateDumpSharedSpace::doit() (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x13d7837e)
    #6 0x7f3629e87f66 in VM_Operation::evaluate() (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x15df0f66)
    #7 0x7f3629f1833e in VMThread::evaluate_operation(VM_Operation*) (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x15e8133e)
    #8 0x7f3629f1b770 in VMThread::inner_execute(VM_Operation*) (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x15e84770)
    #9 0x7f3629f1c68a in VMThread::loop() (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x15e8568a)
    #10 0x7f3629f1ca46 in VMThread::run() (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x15e85a46)
    #11 0x7f36299c68e6 in Thread::call_run() (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x1592f8e6)
    #12 0x7f362838c961 in thread_native_entry(Thread*) (/home/yansendao/git/jdk/build/linux-x86_64-server-fastdebug/support/interim-image/lib/server/libjvm.so+0x142f5961)
    #13 0x7f36405e63fa in start_thread (/lib64/libpthread.so.0+0x93fa)

ASAN leak 已知问题屏蔽方法: 运行时配置环境变量,export LSAN_OPTIONS=suppressions=$HOME/tone/tone-matrix-compiler/jtreg/asan/leak-suppressions.txt leak-suppressions.txt文件内容为每一行屏蔽一个函数方法 leak:函数签名,参考如下:

image

leak-suppressions.txt make-linux-x86_64-server-fastdebug-2.log.zip make-linux-x86_64-server-fastdebug-1.log.zip

sendaoYan commented 1 day ago

https://code.alibaba-inc.com/os-quality/tone-matrix-compiler/codereview/19280798

sendaoYan commented 1 day ago

SymbolTable::write_to_archive调用CompactHashtableWriter writer(int(_items_count), ArchiveBuilder::symbol_stats());