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

Leslie Zhai zhaixiang at loongson.cn
Thu Mar 21 15:58:50 UTC 2019


Hi Erik,


在 2019年03月20日 00:51, Erik Joelsson 写道:
> 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.

Indeed.  Stack alignment issue:

# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/os_linux_x86.cpp:818
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error 
(/home/xiangzhai/project/jdk/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp:818), 
pid=21908, tid=21909
#  assert(((intptr_t)os::current_stack_pointer() & 
(StackAlignmentInBytes-1)) == 0) failed: incorrect stack alignment
#
# JRE version:  (13.0) (fastdebug build )
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 
13-internal+0-adhoc.xiangzhai.jdk, mixed mode, tiered, compressed oops, 
g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x120e3a5]  os::verify_stack_alignment()+0x15
----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---

Martin filed the bug[1].  It also effect jdk12-mips64el.  But jdk8u is 
able to work compiled with clang-8[2].

[1] https://bugs.openjdk.java.net/browse/JDK-8186780
[2] 
https://mail.openjdk.java.net/pipermail/jdk8u-dev/2018-September/007890.html 


>
>
> 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