RFR: 8132725: Memory leak in Arguments::add_property function

Dmitry Dmitriev dmitry.dmitriev at oracle.com
Sun Aug 23 20:51:21 UTC 2015


Hello,

Can I please get review and sponsor for this fix? Thanks!

Dmitry

On 13.08.2015 10:55, Dmitry Dmitriev wrote:
> Hello,
>
> Please review this fix which remove memory leak in 
> Arguments::add_property function. Also, I need a sponsor for this fix, 
> who can push it.
>
> Arguments::add_property function allocate memory for key and value. 
> Then key and values are passed to the PropertyList_unique_add function 
> which use SystemProperty class to add or update property value. 
> SystemProperty class maintains it's own copy of key and value and thus 
> copy passed key and value. Therefore key and value must be freed in 
> add_property function(with exception for value in case of 
> "java.vendor.url.bug" and "sun.java.command" properties).
>
> In this fix I allocate memory only for key when passed property 
> contains value. If passed property not contains value, then I not 
> allocate memory for key and use passed property string. Value also 
> extracted from passed property string instead of allocating. To 
> accomplish that I changed declaration of "value" in several functions 
> from "char *" to  "const char *" since value is not modified in these 
> functions(PropertyList_* functions, SystemProperty class methods).
>
> Processing of "java.vendor.url.bug" and "sun.java.command" properties 
> also corrected. Now when these properties redefined, then code checks 
> if memory was allocated for special variables of these 
> properties(checking that not contains default value) and free it.
>
> Webrev: http://cr.openjdk.java.net/~ddmitriev/8132725/webrev.00/ 
> <http://cr.openjdk.java.net/%7Eddmitriev/8132725/webrev.00/>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8132725
> Tested: JPRT(hotspot test set), hotspot all, vm.quick
>
> Thanks,
> Dmitry



More information about the hotspot-runtime-dev mailing list