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

erronous free in RegClass::~RegClass()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u112, 9
    • hotspot
    • b89

        Freeing _classid in the destructor of RegClass is likely to be erronous. Here is the explanation provided by Krystal Mok:

        "When I was looking at the call chain that leads to RegClass' constructor, get_ident() is what's passed into RegClass as classid.

        The comment on get_ident_common() says:
        http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/ac291bc3ece2/src/share/vm/adlc/adlparse.cpp#l4560
        //------------------------------get_ident_common-------------------------------
        // Looks for an identifier in the buffer, and turns it into a null terminated
        // string(still inside the file buffer). Returns a pointer to the string or
        // NULL if some other token is found instead.
        char *ADLParser::get_ident_common(bool do_preproc) {

        So normally, the string returned should be still inside the file buffer (if no preprocessing is needed...), and shouldn't need to be free'd afterwards; but if preprocessing is needed, then yes, there's dynamically allocated memory for the string returned.
        get_ident() is get_ident_common(true), so it's possible that preprocessing is needed; but from the RegClass constructor, it'd be hard to tell whether the string passed in is from the file buffer or from a dynamically allocated piece of memory."

              zmajo Zoltan Majo (Inactive)
              zmajo Zoltan Majo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: