RFR (XS): 8132892: Memory must be freed after calling Arguments::set_sysclasspath function
Daniel D. Daugherty
daniel.daugherty at oracle.com
Fri Aug 7 16:27:43 UTC 2015
On 8/4/15 3:14 AM, Dmitry Dmitriev wrote:
> Hello,
>
> Please review this small fix which fix small memory leak. Also, I need
> a sponsor for this fix, who can push it.
>
> Arguments::set_sysclasspath function call set_value method of
> SystemProperty class which copy passed value. In several code paths
> memory is allocated for string and then this string is passed to
> Arguments::set_sysclasspath. Therefore allocated string should be
> freed after calling Arguments::set_sysclasspath function.
>
> Webrev: http://cr.openjdk.java.net/~ddmitriev/8132892/webrev.00/
> <http://cr.openjdk.java.net/%7Eddmitriev/8132892/webrev.00/>
src/share/vm/runtime/arguments.cpp
src/share/vm/runtime/os.cpp
L1162: char* os::format_boot_path(const char* format_string, ...
Not your bug, but:
format_boot_path() is only called from os.cpp so I have
to wonder why it is named in the 'os' class instead of
being private to os.cpp. Perhaps this is worth a cleanup
RFE...
L1286: FREE_C_HEAP_ARRAY(char, modules_dir);
Please set modules_dir = NULL after the free to prevent
accidental post-free use; the other free calls are fine
because they are closely followed by a return.
Thumbs up. Adding the "modules_dir = NULL" is your choice
and I don't need a re-review if you choose to do it.
Dan
> JBS: https://bugs.openjdk.java.net/browse/JDK-8132892
> Tested: JPRT(hotspot test set), hotspot all, vm.quick
>
> Thanks,
> Dmitry
>
>
More information about the hotspot-runtime-dev
mailing list