RFR: 8353189: [ASAN] memory leak after 8352184
SendaoYan
syan at openjdk.org
Mon Apr 7 13:14:37 UTC 2025
On Tue, 1 Apr 2025 01:19:42 GMT, SendaoYan <syan at openjdk.org> wrote:
> Maybe you want to cache version string, just as `vm_release` string [here](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/abstract_vm_version.cpp#L32).
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 `Abstract_VM_Version::vm_info_string()` at the third times then get `compiled mode`. After this PR, jvm will only cache the version string at the first time. So cache version string seems can't solve this memory leak issue.
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" : "",
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24299#issuecomment-2769289318
More information about the hotspot-dev
mailing list