RFR(S): 8039805: Fix the signature of the global new/delete operators in allocation.cpp

Volker Simonis volker.simonis at gmail.com
Wed Apr 9 22:21:53 UTC 2014

On Wednesday, April 9, 2014, Thomas Stüfe <thomas.stuefe at gmail.com> wrote:

> Hi Volker,
>> This change also replaces the asserts in the operators with guarantees
>> because the code may also be active in not-product (aka. 'optimized')
>> builds.
> I think defining global operator new in production code would be a bad
> idea;

But that's not what I want and not what I actually did. As I wrote, the
global operators are only defined in a not-product configuration. That's
exactly how it should be and I didn't change that.

'optimized' is a Hotspot build configuration which builds the Hotspot in
optimized mode but without defining 'PRODUCT' - i.e. an optimized
non-product build (just take look at the Hotspot make files). Of course you
have no assertions in an optimized build, that's why I changed the asserts
in the global operators into guarantees.

In a 'release' build - i.e. and an optimized product build, the global
operators (and thus the guarantees) of course won't be visible because
of the obvious reasons mentioned by you and by the corresponding comments
in allocation.cpp.


> the most obvious reason would be that any third party binary loaded into
> the
> process space could do a new() which would trigger the guarantee.
> So, I'd prefer a
>  #ifndef ASSERT
>  #error
>  #endif
> in the code...
> If we really want to enable global operator new/delete for production
> code, we
> should provide allocations instead of guaranteeing or returning NULL.
> But this still would be dangerous, mainly because it is possible that
> other
> libraries bring their own versions of op new/delete and they may interfere
> with our operators.
> Kind Regards, Thomas

More information about the hotspot-dev mailing list