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

Node::operator new invokes undefined behavior

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b131
    • CPU:
      generic
    • OS:
      generic

      Description

      Node::operator new looks like:

      inline void* operator new(size_t x) throw() {
         Compile* C = Compile::current();
         Node* n = (Node*)C->node_arena()->Amalloc_D(x);
      #ifdef ASSERT
         n->_in = (Node**)n; // magic cookie for assertion check
      #endif
         return (void*)n;
       }

      That assignment of n->_in is, in this context, undefined behavior. Applying member access (either data or function) to storage before the constructor has been applied to it (or after the destructor) is undefined behavior.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlong Dean Long
                Reporter:
                kbarrett Kim Barrett
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: