Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8297138

UB leading to crash in Amalloc with optimized builds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 21
    • 20
    • hotspot
    • generic

      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.

            azafari Afshin Zafari
            aph Andrew Haley
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: