storage leak in TempNewSymbol?

Coleen Phillimore coleen.phillimore at oracle.com
Wed May 2 18:32:47 PDT 2012


Yes, I believe you are right.   This would make a good white box test.   
I'll file a bug (if you haven't already).
Thanks,
Coleen

On 5/2/2012 6:34 PM, John Rose wrote:
> 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