RFR: 8347758: modules.cpp leaks string returned from get_numbered_property_as_sorted_string() [v4]
Zhengyu Gu
zgu at openjdk.org
Thu Jan 16 14:10:37 UTC 2025
On Thu, 16 Jan 2025 01:04:49 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> src/hotspot/share/classfile/modules.cpp line 639:
>>
>>> 637:
>>> 638: const char* Modules::get_native_access_flags_as_sorted_string() {
>>> 639: assert(Thread::current()->current_resource_mark() != nullptr, "Setup by caller");
>>
>> I think these asserts are redundant. st.as_string() will fail if there are no resource marks. We have plenty of functions that return a resurce-allocated object and it's uncommon to add such asserts.
>
> Agreed. We detect missing ResourceMarks so there is no need to check for present ones.
I added the assertion to prevent installing `ResourceMark` here, which will result in returning invalid string. @dholmes-ora suggested additional comment, but I prefer assertion.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23121#discussion_r1918614091
More information about the hotspot-runtime-dev
mailing list