-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8347758: modules.cpp leaks string returned from get_numbered_property_as_sorted_string() #23121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c0542c4
8347758: modules.cpp leaks string returned from get_numbered_property…
zhengyu123 e4ab2bb
Avoid copying strings
d553afa
Calvin's comment
01ffa01
Assertion in wrong place
be5f90f
David's comment
5131735
Move RM close to use
e970075
David's comment
zhengyu123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||
| /* | ||||||||
| * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. | ||||||||
| * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. | ||||||||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||||||||
| * | ||||||||
| * This code is free software; you can redistribute it and/or modify it | ||||||||
|
|
@@ -628,19 +628,22 @@ void Modules::serialize(SerializeClosure* soc) { | |||||||
| } | ||||||||
|
|
||||||||
| void Modules::dump_native_access_flag() { | ||||||||
| ResourceMark rm; | ||||||||
| const char* native_access_names = get_native_access_flags_as_sorted_string(); | ||||||||
| if (native_access_names != nullptr) { | ||||||||
| _archived_native_access_flags = ArchiveBuilder::current()->ro_strdup(native_access_names); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // Caller needs ResourceMark | ||||||||
| const char* Modules::get_native_access_flags_as_sorted_string() { | ||||||||
| return get_numbered_property_as_sorted_string("jdk.module.enable.native.access"); | ||||||||
| } | ||||||||
|
|
||||||||
| void Modules::serialize_native_access_flags(SerializeClosure* soc) { | ||||||||
| soc->do_ptr(&_archived_native_access_flags); | ||||||||
| if (soc->reading()) { | ||||||||
| ResourceMark rm; | ||||||||
| check_archived_flag_consistency(_archived_native_access_flags, get_native_access_flags_as_sorted_string(), "jdk.module.enable.native.access"); | ||||||||
|
|
||||||||
| // Don't hold onto the pointer, in case we might decide to unmap the archive. | ||||||||
|
|
@@ -649,28 +652,31 @@ void Modules::serialize_native_access_flags(SerializeClosure* soc) { | |||||||
| } | ||||||||
|
|
||||||||
| void Modules::dump_addmods_names() { | ||||||||
| ResourceMark rm; | ||||||||
| const char* addmods_names = get_addmods_names_as_sorted_string(); | ||||||||
| if (addmods_names != nullptr) { | ||||||||
| _archived_addmods_names = ArchiveBuilder::current()->ro_strdup(addmods_names); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // Caller needs ResourceMark | ||||||||
| const char* Modules::get_addmods_names_as_sorted_string() { | ||||||||
| return get_numbered_property_as_sorted_string("jdk.module.addmods"); | ||||||||
| } | ||||||||
|
|
||||||||
| void Modules::serialize_addmods_names(SerializeClosure* soc) { | ||||||||
| soc->do_ptr(&_archived_addmods_names); | ||||||||
| if (soc->reading()) { | ||||||||
| ResourceMark rm; | ||||||||
| check_archived_flag_consistency(_archived_addmods_names, get_addmods_names_as_sorted_string(), "jdk.module.addmods"); | ||||||||
|
|
||||||||
| // Don't hold onto the pointer, in case we might decide to unmap the archive. | ||||||||
| _archived_addmods_names = nullptr; | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // Caller needs ResourceMark | ||||||||
| const char* Modules::get_numbered_property_as_sorted_string(const char* property) { | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| ResourceMark rm; | ||||||||
| // theoretical string size limit for decimal int, but the following loop will end much sooner due to | ||||||||
| // OS command-line size limit. | ||||||||
| const int max_digits = 10; | ||||||||
|
|
@@ -723,7 +729,7 @@ const char* Modules::get_numbered_property_as_sorted_string(const char* property | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| return (st.size() > 0) ? os::strdup(st.as_string()) : nullptr; // Example: "java.base,java.compiler" | ||||||||
| return (st.size() > 0) ? st.as_string() : nullptr; // Example: "java.base,java.compiler" | ||||||||
| } | ||||||||
|
|
||||||||
| void Modules::define_archived_modules(Handle h_platform_loader, Handle h_system_loader, TRAPS) { | ||||||||
|
|
||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.