RFR: 8186780: clang fastdebug assertion failure in os_linux_x86:os::verify_stack_alignment()

Jiangli Zhou jianglizhou at google.com
Tue Mar 17 16:41:15 UTC 2020


Yes, the solution looks good to me.

(Duplicating one of the comment from JDK-8186780 here)The Clang
generated code for a fastdebug build looks like this when
__builtin_frame_address() is used:

(gdb) x/i $pc-4
0x7ffff748d820 <os::verify_stack_alignment()>: push %rbp
(gdb)
0x7ffff748d821 <os::verify_stack_alignment()+1>: mov %rsp,%rbp
(gdb)
=> 0x7ffff748d824 <os::verify_stack_alignment()+4>: test $0xf,%bpl
(gdb)

%bpl is the lower 8-bit of %rbp. With the __builtin_frame_address()
call, it forces the compiler to emit 'push %rbp; mov %rsp, %rbp',
which does the necessary stack adjustment before the test.

Earlier I had a concern about using __builtin_frame_address(0) for gcc
case. According to
https://github.com/google/glog/blob/master/src/stacktrace_x86-inl.h#L113,
__builtin_frame_address(0) can return the wrong address on
gcc-4.1.0-k8. However, gcc-4.1.0 is very old (>=13 year old). Martin
also pointed out that __builtin_frame_address(0) is already being used
unconditionally elsewhere in hotspot, for example in
os_linux_zero.cpp. So the change seems to be safe.

Best regards,
Jiangli

On Mon, Mar 16, 2020 at 8:46 PM Martin Buchholz <martinrb at google.com> wrote:
>
> We finally came up with a solution for this that more than one engineer can agree on:
>
> https://cr.openjdk.java.net/~martin/webrevs/jdk/clang-stack-alignment-builtin-frame-address/
> https://bugs.openjdk.java.net/browse/JDK-8186780


More information about the hotspot-runtime-dev mailing list