Print this page
rev 4505 : 8014189: JVM crash with SEGV in ConnectionGraph::record_for_escape_analysis()
Summary: Add NULL checks and asserts for Type::make_ptr() returned value.
Reviewed-by: kvn

Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/opto/escape.cpp
          +++ new/src/share/vm/opto/escape.cpp
↓ open down ↓ 456 lines elided ↑ open up ↑
 457  457        // fallthrough
 458  458      }
 459  459      case Op_StoreP:
 460  460      case Op_StoreN:
 461  461      case Op_StorePConditional:
 462  462      case Op_CompareAndSwapP:
 463  463      case Op_CompareAndSwapN: {
 464  464        Node* adr = n->in(MemNode::Address);
 465  465        const Type *adr_type = igvn->type(adr);
 466  466        adr_type = adr_type->make_ptr();
      467 +      if (adr_type == NULL) {
      468 +        break; // skip dead nodes
      469 +      }
 467  470        if (adr_type->isa_oopptr() ||
 468  471            (opcode == Op_StoreP || opcode == Op_StoreN) &&
 469  472                          (adr_type == TypeRawPtr::NOTNULL &&
 470  473                           adr->in(AddPNode::Address)->is_Proj() &&
 471  474                           adr->in(AddPNode::Address)->in(0)->is_Allocate())) {
 472  475          delayed_worklist->push(n); // Process it later.
 473  476  #ifdef ASSERT
 474  477          assert(adr->is_AddP(), "expecting an AddP");
 475  478          if (adr_type == TypeRawPtr::NOTNULL) {
 476  479            // Verify a raw address for a store captured by Initialize node.
↓ open down ↓ 168 lines elided ↑ open up ↑
 645  648        ELSE_FAIL("Op_Return");
 646  649      }
 647  650      case Op_StoreP:
 648  651      case Op_StoreN:
 649  652      case Op_StorePConditional:
 650  653      case Op_CompareAndSwapP:
 651  654      case Op_CompareAndSwapN:
 652  655      case Op_GetAndSetP:
 653  656      case Op_GetAndSetN: {
 654  657        Node* adr = n->in(MemNode::Address);
 655      -      if (opcode == Op_GetAndSetP || opcode == Op_GetAndSetN) {
 656      -        const Type* t = _igvn->type(n);
 657      -        if (t->make_ptr() != NULL) {
 658      -          add_local_var_and_edge(n, PointsToNode::NoEscape, adr, NULL);
 659      -        }
 660      -      }
 661  658        const Type *adr_type = _igvn->type(adr);
 662  659        adr_type = adr_type->make_ptr();
      660 +#ifdef ASSERT
      661 +      if (adr_type == NULL) {
      662 +        n->dump(1);
      663 +        assert(adr_type != NULL, "dead node should not be on list");
      664 +        break;
      665 +      }
      666 +#endif
      667 +      if (opcode == Op_GetAndSetP || opcode == Op_GetAndSetN) {
      668 +        add_local_var_and_edge(n, PointsToNode::NoEscape, adr, NULL);
      669 +      }
 663  670        if (adr_type->isa_oopptr() ||
 664  671            (opcode == Op_StoreP || opcode == Op_StoreN) &&
 665  672                          (adr_type == TypeRawPtr::NOTNULL &&
 666  673                           adr->in(AddPNode::Address)->is_Proj() &&
 667  674                           adr->in(AddPNode::Address)->in(0)->is_Allocate())) {
 668  675          // Point Address to Value
 669  676          PointsToNode* adr_ptn = ptnode_adr(adr->_idx);
 670  677          assert(adr_ptn != NULL &&
 671  678                 adr_ptn->as_Field()->is_oop(), "node should be registered");
 672  679          Node *val = n->in(MemNode::ValueIn);
↓ open down ↓ 1102 lines elided ↑ open up ↑
1775 1782          return _pcmp_neq; // This includes nullness check.
1776 1783        }
1777 1784      }
1778 1785    }
1779 1786    if (jobj1 != NULL && jobj1 != phantom_obj &&
1780 1787        jobj2 != NULL && jobj2 != phantom_obj &&
1781 1788        jobj1->ideal_node()->is_Con() &&
1782 1789        jobj2->ideal_node()->is_Con()) {
1783 1790      // Klass or String constants compare. Need to be careful with
1784 1791      // compressed pointers - compare types of ConN and ConP instead of nodes.
1785      -    const Type* t1 = jobj1->ideal_node()->bottom_type()->make_ptr();
1786      -    const Type* t2 = jobj2->ideal_node()->bottom_type()->make_ptr();
1787      -    assert(t1 != NULL && t2 != NULL, "sanity");
     1792 +    const Type* t1 = jobj1->ideal_node()->get_ptr_type();
     1793 +    const Type* t2 = jobj2->ideal_node()->get_ptr_type();
1788 1794      if (t1->make_ptr() == t2->make_ptr()) {
1789 1795        return _pcmp_eq;
1790 1796      } else {
1791 1797        return _pcmp_neq;
1792 1798      }
1793 1799    }
1794 1800    if (ptn1->meet(ptn2)) {
1795 1801      return NULL; // Sets are not disjoint
1796 1802    }
1797 1803  
↓ open down ↓ 1456 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX