Fail to make images when enable ASan for OpenJDK X86 with LLVM toolchain

Erik Joelsson erik.joelsson at oracle.com
Tue Mar 19 16:51:35 UTC 2019


Hello Leslie,

The failure you see is happening when the newly built exploded image is 
used for the first time. I'm not familiar with ASAN, but it seems that 
the JDK you create does not quite work. There are some ways around this.

If you are unfamiliar with the exploded image, it's something we create 
while building everything (classes, libraries etc) that can run 
directly, but will not be as performant as the real jlinked image that 
the "images" target creates. Normally you build this with "make 
exploded-image" or "make jdk", but this includes the optimization step 
that is failing for you. To build just the exploded image and skip the 
optimization step, you can run "make exploded-image-base". In the build 
output you find the exploded image in 
build/linux-x86_64-server-fastdebug/jdk.  After your failure, you should 
be able to investigate this image by running things directly in it. From 
there you should be able to see if there is a problem with the binaries 
you built.

Another thing that could help you (perhaps not right now since it fails 
too early, but in general when you add special instrumentation to the 
build) is to first build a normal JDK. Then when you configure your 
special build, add --with-build-jdk=/path/to/normal/image. The 
"build-jdk" must exactly match the sources of the special build you are 
building and will be used for running all the jmod/jlink etc steps in 
the build instead of your special JDK build.

/Erik

On 2019-03-19 08:33, Leslie Zhai wrote:
> Hi,
>
> I want to run dynamic analysis test with the help of Address 
> Sanitizer.  And I read the blog 'Running Java with 
> AddressSanitizer'[1]  wrote by Artem who also added support for 
> ASan[2].  Thanks for his great job!
>
> But I failed to make images for X86:
>
> Compiling 4 files for BUILD_JIGSAW_TOOLS
> ERROR: Invalid value for bool option: '0"'
> ERROR: Flag parsing failed.
> ExplodedImageOptimize.gmk:39: recipe for target 
> '/home/xiangzhai/project/jdk/build/linux-x86_64-server-fastdebug/jdk/_optimize_image_exec.marker' 
> failed
> gmake[3]: *** 
> [/home/xiangzhai/project/jdk/build/linux-x86_64-server-fastdebug/jdk/_optimize_image_exec.marker] 
> Error 1
> make/Main.gmk:372: recipe for target 'exploded-image-optimize' failed
> gmake[2]: *** [exploded-image-optimize] Error 1
>
> ERROR: Build failed for target 'images' in configuration 
> 'linux-x86_64-server-fastdebug' (exit code 2)
> Stopping sjavac server
>
> === Output from failing command(s) repeated here ===
> * For target jdk__optimize_image_exec:
> ERROR: Invalid value for bool option: '0"'
> ERROR: Flag parsing failed.
>
> ----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---
>
> jdk__optimize_image_exec.cmdline[3], jdk__optimize_image_exec.log[4],  
> and dynamic analysis report[5] by running the cmdline.
>
> using configure arguments '--with-toolchain-type=clang 
> --disable-warnings-as-errors --enable-asan 
> --with-boot-jdk=/home/xiangzhai/jdk-11.0.2 --with-debug-level=fastdebug'
>
> ----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---
>
> And I also make images with extra CFLAGS, CXXFLAGS and LDFLAGS to 
> enable TSan for mips64el with LLVM toolchain especially integrated 
> assembler:
>
> sh configure --with-toolchain-type=clang \
>   --disable-warnings-as-errors \
> --with-boot-jdk=/home/loongson/zhaixiang/jdk-mips-f21-build-server-release-072 
> \
>   --with-debug-level=fastdebug \
>   --with-extra-cflags="-fintegrated-as -fsanitize=thread" \
>   --with-extra-cxxflags="-fintegrated-as -fsanitize=thread" \
>   --with-extra-ldflags="-fsanitize=thread"
>
> Although successfully built libjvm.so,  it means make hotspot works,  
> failed to bootstrap near the end of make images.
>
> So workaround might be make images at first without ASan nor TSan, 
> then make hotspot with ASan or TSan?
>
> Thanks,
>
> Leslie Zhai
>
> [1] 
> https://blog.gypsyengineer.com/en/security/running-java-with-addresssanitizer.html
>
> [2] https://bugs.openjdk.java.net/browse/JDK-8189800
>
> [3] 
> https://raw.githubusercontent.com/xiangzhai/jdk-dev/master/jdk__optimize_image_exec.cmdline
>
> [4] 
> https://raw.githubusercontent.com/xiangzhai/jdk-dev/master/jdk__optimize_image_exec.log
>
> [5] 
> https://raw.githubusercontent.com/xiangzhai/jdk-dev/master/make-enable-asan.log
>
>


More information about the build-dev mailing list