Undefined behaviour in HotSpot

Andrew Haley aph at redhat.com
Tue Dec 1 16:56:34 UTC 2015


I've been kicking the tyres of the undefined behaviour sanitizer in
GCC.  It picks up a few spurious errors in HotSpot but some serious
ones too.  In particular, there are many integer overflows in C2, and
these can lead to incorrect code generation.  I don't know that they
actually cause any problems, but I do know that GCC's optimizations
"know" that signed integer overflows never occur and generate code
accordingly.

Some of the code in C2 which checks for overflow (e.g.
AddLNode::add_ring) looks very wrong to me.  I am not comfortable that
an aggressive C++ optimizing compiler will generate the expected code
for this function.

Would it be useful at this stage in JDK9 to fix these?  If so, I can
create some bug reports and webrevs.

Andrew.


More information about the hotspot-compiler-dev mailing list