RFR: JDK-8304684: Memory leak in DirectivesParser::set_option_flag [v2]

Dean Long dlong at openjdk.org
Fri Mar 24 00:06:30 UTC 2023


On Thu, 23 Mar 2023 23:39:10 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Right, the ownership of the string seems unclear.  If we try to free the string storage in ~DirectiveSet I think it will result in a double free, because clone() appears to do a shallow copy.
>
> Worse yet, it looks like the default value can point to the existing storage of the DisableIntrinsic and ControlIntrinsic global values, making it doubly hard to know if the storage can be freed, unless we get rid of simple = assignment and always allocate new memory when assigning the string values.
> But why re-invent the wheel?  Can't we use something like C++ std::string to manage the lifetimes for us?

Or maybe ~DirectiveSet could use the _modified array to decide if it should free the string flags.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13125#discussion_r1146989162


More information about the hotspot-compiler-dev mailing list