RFR: JDK-8160354: uninitialized value warning and VM crash are occurred with GCC 6
Kim Barrett
kim.barrett at oracle.com
Tue Jun 28 00:10:10 UTC 2016
> On Jun 27, 2016, at 6:12 PM, Kim Barrett <kim.barrett at oracle.com> wrote:
>> On Jun 27, 2016, at 10:29 AM, Yasumasa Suenaga <yasuenag at gmail.com> wrote:
>>
>> Hi all,
>>
>> This review request relates to JDK-8160310: HotSpot cannot be built with GCC 6 .
>>
>> I encountered 2 compiler warnings and 2 VM crashes when I compiled OpenJDK 9 with
>> GCC 6 on Fedora 24 x64.
>> I think these error should be fixed.
>>
>> I uploaded webrev.
>> Could you review it?
>>
>> http://cr.openjdk.java.net/~ysuenaga/JDK-8160354/webrev.00/
>
> src/cpu/x86/vm/assembler_x86.cpp
> 191 RelocationHolder rspec = (disp_reloc == relocInfo::none)
> 192 ? RelocationHolder::none
> 193 : rspec = Relocation::spec_simple(disp_reloc);
>
> I have no idea what is being attempted by this change, but I really
> doubt this is correct. The precedence of ?: is higher than the
> precedence of =.
>
> I think I see what might be going wrong with the original code.
>
> RelocationHolder has a _relocbuf member, which is really just storage
> for a Relocation object. The constructors for RelocationHolder are
> both problematic, but the no-arg constructor is the one at fault here.
>
> RelocationHolder::RelocationHolder() {
> new(*this) Relocation();
> }
>
> This is constructing a different object over the current, which is
> undefined behavior, so gcc 6 is perhaps eliding it, leading to the
> failure. What this should actually be doing is using the start of the
> _relocbuf member as the placement new location.
No, that analysis is wrong.
That isn't a placement new, it's new with another argument to the
allocator, specifically this holder.
I suspect the initialization of _relocbuf below might be related.
> src/share/vm/code/relocInfo.hpp
> 495 void* _relocbuf[ _relocbuf_size ] = {0};
>
> I'm not sure why this might be needed, but I don't think this is valid
> C++98 code. I think this is actually using a C++14 feature.
More information about the hotspot-dev
mailing list