In Amalloc() we do this:
debug_only(if (UseMallocOnly) return malloc(x);)
so, if and only if DEBUG is on do we use malloc().
However, the matching free() in ResourceArea::rollback_to() does not have a matching debug_only guard:
if (UseMallocOnly) {
free_malloced_objects ...
UseMallocOnly is a product flag. So, if PRODUCT is true, and DEBUG is true, we have a mismatched malloc() and free(). This is undefined behaviour.
I suggest we should remove the debug_only guard.
debug_only(if (UseMallocOnly) return malloc(x);)
so, if and only if DEBUG is on do we use malloc().
However, the matching free() in ResourceArea::rollback_to() does not have a matching debug_only guard:
if (UseMallocOnly) {
free_malloced_objects ...
UseMallocOnly is a product flag. So, if PRODUCT is true, and DEBUG is true, we have a mismatched malloc() and free(). This is undefined behaviour.
I suggest we should remove the debug_only guard.
- relates to
-
JDK-8297766 Remove UseMallocOnly development option
-
- Resolved
-
- links to
-
Review openjdk/jdk/11320