RFR: 8303070: Memory leak in DCmdArgument<char*>::parse_value

Mikael Vidstedt mikael at openjdk.org
Fri Feb 24 00:57:14 UTC 2023


On Fri, 24 Feb 2023 00:26:13 GMT, David Holmes <dholmes at openjdk.org> wrote:

> If we have a default value for the char* DCmdArgument we copy it into the `_value` field using `parse_value` to make a copy in C-heap. If we then parse an actual argument value, we replace the default but don't free it. The parse method needs to use realloc.
> 
> Thanks to @jcking for spotting the cause.
> 
> Testing: tiers 1-3 
> 
> Thanks.

src/hotspot/share/services/diagnosticArgument.cpp line 195:

> 193:   if (has_default() && _default_string != nullptr) {
> 194:     this->parse_value(_default_string, strlen(_default_string), THREAD);
> 195:     if (HAS_PENDING_EXCEPTION) {

Why drop the exception check? Can `parse_value` not raise an exception?

-------------

PR: https://git.openjdk.org/jdk/pull/12737


More information about the hotspot-runtime-dev mailing list