storage leak in TempNewSymbol?

John Rose john.r.rose at oracle.com
Wed May 2 15:34:23 PDT 2012


It looks like there is a state transition for TempNewSymbol which leaks storage.

If the contract is "TNS will always decrement the refcount of its target", then this contract will be broken by the assignment operator.

Failing test case:
  { TempNewSymbol sym = SymbolTable::probe("no such symbol", 3);
    sym = NULL; }

Suggested fix is below.  Comments?

— John

diff --git a/src/share/vm/classfile/symbolTable.hpp b/src/share/vm/classfile/symbolTable.hpp
--- a/src/share/vm/classfile/symbolTable.hpp
+++ b/src/share/vm/classfile/symbolTable.hpp
@@ -56,6 +56,7 @@
 
   // Operator= increments reference count.
   void operator=(const TempNewSymbol &s) {
+    if (_temp != NULL) _temp->decrement_refcount();
     _temp = s._temp;
     if (_temp != NULL) _temp->increment_refcount();
   }



More information about the hotspot-runtime-dev mailing list