Undefined behaviour in hotspot

Omair Majid omajid at redhat.com
Mon Apr 21 16:17:48 UTC 2014

* David Chase <david.r.chase at oracle.com> [2014-04-21 11:53]:
> On 2014-04-21, at 11:19 AM, Omair Majid <omajid at redhat.com> wrote:
> > I recently tried to build OpenJDK on i686 using a prerelease version of GCC
> > 4.9. It turns out that new optimizations have been enabled in GCC which now
> > cause hotspot to break in a few places where hotspot relies on undefined
> > behaviour.
> > ...
> > Dereferencing a NULL pointer is undefined behaviour in C++ [5] and it seems
> > perfectly acceptable for a compiler to compile hotspot in a way so that it ends
> > up not working.
> > Obviously, I would like to get hotspot to work correctly when compiled against
> > GCC 4.9. But I believe the micro-optimizations made to use the address of the
> > object instead of using a field in the object is to save space and I would
> > rather not blindly undo it. Does anyone here have any advice on what the best
> > course of action there is?
> Is there a chance that (because you work for redhat) you might have
> some influence over the gcc implementers, and get them to
> implement/document a flag or pragma that will cause it to cut that
> crap out?

I can ping them, but honestly, I wouldn't be surprised at all if the
only response I get is "no". I don't have any official communication
channels with them, so my input is not any different from anyone else's.

Can you elaborate on what flag/pragma you have in mind? Just something
to play nice with NULL pointers?

> So, step one is to locate all the places where undefined behavior
> occurs, and then we have to figure out what to do next, but we can't
> do anything without knowing the full scope of the problem.

Static analysis tools would come in handy here:
- gcc's -fsanitize=address|thread|undefined
- clang static analyzer
- cppcheck
- coverity

Should I start running whatever tools I can get my hands on and
gathering results?


PGP Key: 66484681 (http://pgp.mit.edu/)
Fingerprint = F072 555B 0A17 3957 4E95  0056 F286 F14F 6648 4681

More information about the hotspot-dev mailing list