-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8353189: [ASAN] memory leak after 8352184 #24299
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
Conversation
|
👋 Welcome back syan! A progress list of the required criteria for merging this PR into |
|
@sendaoYan This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 218 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
@sendaoYan The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
|
You can't just free the result as it may not have always been malloc'd. The intention/expectation was that this was a one-off allocation in VM_version_string that was never freed. |
|
Maybe you want to cache version string, just as |
Thanks, I will try it later. |
Below patch is try to cache version string, this patch will fix the memory leak error, but can't get the right version with -Xcomp mode. Before this PR, jvm call function diff --git a/src/hotspot/share/runtime/abstract_vm_version.cpp b/src/hotspot/share/runtime/abstract_vm_version.cpp
index 763e441fe54..cd81d89c31f 100644
--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
@@ -31,6 +31,7 @@
const char* Abstract_VM_Version::_s_vm_release = Abstract_VM_Version::vm_release();
const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Version::internal_vm_info_string();
+const char* Abstract_VM_Version::_s_vm_info_string = Abstract_VM_Version::vm_info_string();
uint64_t Abstract_VM_Version::_features = 0;
const char* Abstract_VM_Version::_features_string = "";
diff --git a/src/hotspot/share/runtime/abstract_vm_version.hpp b/src/hotspot/share/runtime/abstract_vm_version.hpp
index 8cfc7031f97..0b8a3c662d0 100644
--- a/src/hotspot/share/runtime/abstract_vm_version.hpp
+++ b/src/hotspot/share/runtime/abstract_vm_version.hpp
@@ -50,6 +50,9 @@ class Abstract_VM_Version: AllStatic {
friend class VMStructs;
friend class JVMCIVMStructs;
+ public:
+ static const char* _s_vm_info_string;
+
protected:
static const char* _s_vm_release;
static const char* _s_internal_vm_info_string;
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
index 8de6f427c3f..dae2199e738 100644
--- a/src/hotspot/share/runtime/arguments.cpp
+++ b/src/hotspot/share/runtime/arguments.cpp
@@ -390,7 +390,7 @@ void Arguments::init_system_properties() {
PropertyList_add(&_system_properties, new SystemProperty("jdk.debug", VM_Version::jdk_debug_level(), false));
// Initialize the vm.info now, but it will need updating after argument parsing.
- _vm_info = new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true);
+ _vm_info = new SystemProperty("java.vm.info", VM_Version::_s_vm_info_string, true);
// Following are JVMTI agent writable properties.
// Properties values are set to nullptr and they are
@@ -1326,7 +1326,7 @@ void Arguments::set_mode_flags(Mode mode) {
// Ensure Agent_OnLoad has the correct initial values.
// This may not be the final mode; mode may change later in onload phase.
PropertyList_unique_add(&_system_properties, "java.vm.info",
- VM_Version::vm_info_string(), AddProperty, UnwriteableProperty, ExternalProperty);
+ VM_Version::_s_vm_info_string, AddProperty, UnwriteableProperty, ExternalProperty);
UseInterpreter = true;
UseCompiler = true;
diff --git a/src/hotspot/share/runtime/threads.cpp b/src/hotspot/share/runtime/threads.cpp
index 32859bf2718..319e238ee5f 100644
--- a/src/hotspot/share/runtime/threads.cpp
+++ b/src/hotspot/share/runtime/threads.cpp
@@ -651,7 +651,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// is initially computed. See Abstract_VM_Version::vm_info_string().
// This update must happen before we initialize the java classes, but
// after any initialization logic that might modify the flags.
- Arguments::update_vm_info_property(VM_Version::vm_info_string());
+ Arguments::update_vm_info_property(VM_Version::_s_vm_info_string);
JavaThread* THREAD = JavaThread::current(); // For exception macros.
HandleMark hm(THREAD);
@@ -1334,7 +1334,7 @@ void Threads::print_on(outputStream* st, bool print_stacks,
st->print_cr("Full thread dump %s (%s %s):",
VM_Version::vm_name(),
VM_Version::vm_release(),
- VM_Version::vm_info_string());
+ VM_Version::_s_vm_info_string);
st->cr();
#if INCLUDE_SERVICES
diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp
index c95dd709c84..854f46ff8df 100644
--- a/src/hotspot/share/runtime/vmStructs.cpp
+++ b/src/hotspot/share/runtime/vmStructs.cpp
@@ -702,6 +702,7 @@
\
static_field(Abstract_VM_Version, _s_vm_release, const char*) \
static_field(Abstract_VM_Version, _s_internal_vm_info_string, const char*) \
+ static_field(Abstract_VM_Version, _s_vm_info_string, const char*) \
static_field(Abstract_VM_Version, _features, uint64_t) \
static_field(Abstract_VM_Version, _features_string, const char*) \
static_field(Abstract_VM_Version, _vm_major_version, int) \
diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp
index bbf1fcf9d6f..ba2116ae205 100644
--- a/src/hotspot/share/utilities/vmError.cpp
+++ b/src/hotspot/share/utilities/vmError.cpp
@@ -513,7 +513,7 @@ static void report_vm_version(outputStream* st, char* buf, int buflen) {
(*vendor_version != '\0') ? " " : "", vendor_version,
jdk_debug_level,
VM_Version::vm_release(),
- VM_Version::vm_info_string(),
+ VM_Version::_s_vm_info_string,
TieredCompilation ? ", tiered" : "",
#if INCLUDE_JVMCI
EnableJVMCI ? ", jvmci" : "", |
|
I was also going to suggest caching the vm_info string as it should be the same all the time. I think you have discovered a bug in the way the info is being requested before arguments (like Xcomp) have been processed. That would cause the wrong info string to be recorded by the early callers. |
Thanks @dholmes-ora , I think I need some time to investigate this issue. |
|
I think I should file a separate bug to deal with the problem that the info string can be used before its true value is actually known. |
|
After looking into the details (JDK-8353595) I don't think there is any choice but to re-do JDK-8352184 using the original, purely static uses of the various description strings, as [~jiangli] had proposed. |
| } | ||
|
|
||
|
|
||
| const char* Abstract_VM_Version::vm_info_string() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future benefit, how about also adding a comment explain why we avoid dynamic memory allocation for the vm_info_string here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have add a comment, but my English is not very well. If you have proper description, please let me known.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me, thanks. Please update the contributor properly since the change is from baff6b1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey, that was my original plan also.
By the way, do you mind add David Holmes as contributor also, because he do lots of investigation on this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me!
…he vm_info_string
|
@sendaoYan Unknown command |
|
/contributor add @jianglizhou |
|
@sendaoYan |
dholmes-ora
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Sorry for the delay in getting it reviewed.
Thanks for fixing this.
|
@sendaoYan Syntax:
User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address. |
|
/contributor add @dholmes-ora |
|
@sendaoYan |
|
Thanks for the reviews and suggestions @dholmes-ora @zhengyu123 @jianglizhou /integrate |
|
Going to push as commit 6545e0d.
Your commit was automatically rebased without conflicts. |
|
@sendaoYan Pushed as commit 6545e0d. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi all,
This PR will try to fix memory leak after JDK-8352184. which re-do JDK-8352184 using the original, purely static uses of the various description strings, as @jianglizhou had proposed.
Additional testing:
java -versiontests, the test shell script show as below.JDK-8353189.sh.txt
Progress
Issue
Reviewers
Contributors
<jiangli@openjdk.org><dholmes@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24299/head:pull/24299$ git checkout pull/24299Update a local copy of the PR:
$ git checkout pull/24299$ git pull https://git.openjdk.org/jdk.git pull/24299/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24299View PR using the GUI difftool:
$ git pr show -t 24299Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24299.diff
Using Webrev
Link to Webrev Comment