clang Memory sanitizer (msan) and OpenJDK

Magnus Ihse Bursie magnus.ihse.bursie at oracle.com
Mon Apr 28 20:05:39 UTC 2025


I thought I recognized this issue, and started searching the mail 
archive. Seems the same question was asked last year by ... you. :-)

https://mail.openjdk.org/pipermail/build-dev/2024-August/046011.html

I guess nobody still has a simple answer to give you. I don't understand 
how the msan internal functions are supposed to work, if there is no 
library to link to. Are they added by the compiler?

Maybe you can try patching out -fvisibility=hidden from the compile 
command line to see if that makes any difference.

/Magnus

On 2025-04-25 16:28, Baesken, Matthias wrote:
>
> Hi,  Memory sanitizer
>
> https://clang.llvm.org/docs/MemorySanitizer.html
>
> is supported with the clang toolchain  (e.g. on Linux) ;  
> “MemorySanitizer is a detector of uninitialized memory use”  .
>
> For small examples it is rather easy to use,   you just compile and 
> link   with -fsanitize=memory      (and for better results maybe 
> additionally  -fno-omit-frame-pointer )   .
>
> So I gave it a try with OpenJDK too and added   -fsanitize=memory 
>      to the  C/CXX and LD flags 
>  (--with-extra-cflags=-fsanitize=memory 
> --with-extra-cxxflags=-fsanitize=memory 
> --with-extra-ldflags=-fsanitize=memory ).
>
> As far as compiling single  compilation units this seems to be okay .
>
> But when it comes to executing the new generated binaries in the build 
> process  we unfortunately get  lookup errors / undefined symbols   :
>
> /builddir/jdk/bin/javac: symbol lookup error: 
>  /builddir/jdk/bin/../lib/libjli.so: undefined symbol: __msan_param_tls
>
> Is there something special in our OpenJDK build that causes trouble here ?
>
> Here I found an somewhat similar looking issue :
>
> https://groups.google.com/g/memory-sanitizer/c/xV3OZZCiL9A
>
> where re-exporting symbols is mentioned - is this maybe something that 
> hits us in OpenJDK too ?
>
> For address sanitizer, we set -shared-libasan in the OpenJDK :
>
> https://github.com/openjdk/jdk/blob/5c067232bf21aaca2b7addd2a862e15a8696ffb8/make/autoconf/jdk-options.m4#L449
>
> ASAN_LDFLAGS="$ASAN_LDFLAGS -shared-libasan"
>
> But I could not find something similar for msan .
>
> (btw. I use clang 15.0.7 on SUSE Linux x86_64 in case this matters)
>
> Best regards, Matthias
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/build-dev/attachments/20250428/76ad6d82/attachment-0001.htm>


More information about the build-dev mailing list