From 933f74cdd48380abfad20d28c21222ba07bd57f5 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 12 Dec 2024 13:36:00 -0500 Subject: [PATCH 1/4] test stack size in vma_touches_thread_stack() --- src/hotspot/share/nmt/memMapPrinter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/nmt/memMapPrinter.cpp b/src/hotspot/share/nmt/memMapPrinter.cpp index 34ddb7a871336..0a956a542a284 100644 --- a/src/hotspot/share/nmt/memMapPrinter.cpp +++ b/src/hotspot/share/nmt/memMapPrinter.cpp @@ -172,7 +172,7 @@ static bool vma_touches_thread_stack(const void* from, const void* to, const Thr // Very rarely however is a VMA backing a thread stack folded together with another adjacent VMA by the // kernel. That can happen, e.g., for non-java threads that don't have guard pages. // Therefore we go for the simplest way here and check for intersection between VMA and thread stack. - return range_intersects(from, to, (const void*)t->stack_end(), (const void*)t->stack_base()); + return T->stack_size() != 0 && range_intersects(from, to, (const void*)t->stack_end(), (const void*)t->stack_base()); } struct GCThreadClosure : public ThreadClosure { From 58e34a84b4edd0cc2bbbc712845b7c03d5665239 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 12 Dec 2024 13:37:03 -0500 Subject: [PATCH 2/4] fix param name --- src/hotspot/share/nmt/memMapPrinter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/nmt/memMapPrinter.cpp b/src/hotspot/share/nmt/memMapPrinter.cpp index 0a956a542a284..649ea26bc3a9b 100644 --- a/src/hotspot/share/nmt/memMapPrinter.cpp +++ b/src/hotspot/share/nmt/memMapPrinter.cpp @@ -172,7 +172,7 @@ static bool vma_touches_thread_stack(const void* from, const void* to, const Thr // Very rarely however is a VMA backing a thread stack folded together with another adjacent VMA by the // kernel. That can happen, e.g., for non-java threads that don't have guard pages. // Therefore we go for the simplest way here and check for intersection between VMA and thread stack. - return T->stack_size() != 0 && range_intersects(from, to, (const void*)t->stack_end(), (const void*)t->stack_base()); + return t->stack_size() != 0 && range_intersects(from, to, (const void*)t->stack_end(), (const void*)t->stack_base()); } struct GCThreadClosure : public ThreadClosure { From 4e4f0fe334281fca52a692f74553f11df05c5419 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 13 Dec 2024 11:24:25 -0500 Subject: [PATCH 3/4] implement and use new Thread::stack_base_or_null() method --- src/hotspot/share/nmt/memMapPrinter.cpp | 2 +- src/hotspot/share/runtime/thread.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/nmt/memMapPrinter.cpp b/src/hotspot/share/nmt/memMapPrinter.cpp index 649ea26bc3a9b..d60dc9d26819b 100644 --- a/src/hotspot/share/nmt/memMapPrinter.cpp +++ b/src/hotspot/share/nmt/memMapPrinter.cpp @@ -172,7 +172,7 @@ static bool vma_touches_thread_stack(const void* from, const void* to, const Thr // Very rarely however is a VMA backing a thread stack folded together with another adjacent VMA by the // kernel. That can happen, e.g., for non-java threads that don't have guard pages. // Therefore we go for the simplest way here and check for intersection between VMA and thread stack. - return t->stack_size() != 0 && range_intersects(from, to, (const void*)t->stack_end(), (const void*)t->stack_base()); + return range_intersects(from, to, (const void*)t->stack_end(), (const void*)t->stack_base_or_null()); } struct GCThreadClosure : public ThreadClosure { diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 82f31ece47903..507faa46473bc 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -525,6 +525,7 @@ class Thread: public ThreadShadow { public: // Stack overflow support address stack_base() const DEBUG_ONLY(;) NOT_DEBUG({ return _stack_base; }) + address stack_base_or_null() const { return _stack_base; } void set_stack_base(address base) { _stack_base = base; } size_t stack_size() const { return _stack_size; } void set_stack_size(size_t size) { _stack_size = size; } From af871b7e9a68dcc2b03001665142298603336bf6 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 17 Dec 2024 09:04:33 -0500 Subject: [PATCH 4/4] add comments, un-problemlist tests --- src/hotspot/share/nmt/memMapPrinter.cpp | 1 + src/hotspot/share/runtime/thread.hpp | 1 + test/hotspot/jtreg/ProblemList.txt | 2 -- test/jdk/ProblemList.txt | 2 -- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/nmt/memMapPrinter.cpp b/src/hotspot/share/nmt/memMapPrinter.cpp index d60dc9d26819b..6e25e62a7f476 100644 --- a/src/hotspot/share/nmt/memMapPrinter.cpp +++ b/src/hotspot/share/nmt/memMapPrinter.cpp @@ -172,6 +172,7 @@ static bool vma_touches_thread_stack(const void* from, const void* to, const Thr // Very rarely however is a VMA backing a thread stack folded together with another adjacent VMA by the // kernel. That can happen, e.g., for non-java threads that don't have guard pages. // Therefore we go for the simplest way here and check for intersection between VMA and thread stack. + // Note it is possible to encounter a brand new thread that has not yet initialized its stack fields. return range_intersects(from, to, (const void*)t->stack_end(), (const void*)t->stack_base_or_null()); } diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 507faa46473bc..513294688c62c 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -525,6 +525,7 @@ class Thread: public ThreadShadow { public: // Stack overflow support address stack_base() const DEBUG_ONLY(;) NOT_DEBUG({ return _stack_base; }) + // Needed for code that can query a new thread before the stack has been set. address stack_base_or_null() const { return _stack_base; } void set_stack_base(address base) { _stack_base = base; } size_t stack_size() const { return _stack_size; } diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index af16f9b228ab4..583ae68ff5057 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -135,8 +135,6 @@ serviceability/jvmti/vthread/GetThreadStateMountedTest/GetThreadStateMountedTest serviceability/jvmti/vthread/GetSetLocalTest/GetSetLocalTest.java 8286836 generic-all serviceability/jvmti/vthread/CarrierThreadEventNotification/CarrierThreadEventNotification.java 8333681 generic-all serviceability/dcmd/gc/RunFinalizationTest.java 8227120 generic-all -serviceability/dcmd/vm/SystemDumpMapTest.java 8340401 windows-all -serviceability/dcmd/vm/SystemMapTest.java 8340401 windows-all serviceability/sa/ClhsdbCDSCore.java 8267433,8318754 macosx-x64,macosx-aarch64 serviceability/sa/ClhsdbFindPC.java#xcomp-core 8267433,8318754 macosx-x64,macosx-aarch64 diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 7e4191a734f1a..fe8ebd18f4f28 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -540,8 +540,6 @@ java/io/IO/IO.java 8337935 linux-pp com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all -com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java 8340401 windows-all - java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all java/lang/management/MemoryMXBean/PendingAllGC.sh 8158837 generic-all