Skip to content

Commit 31858fc

Browse files
author
David Holmes
committed
8340491: Thread stack-base assertion should report which thread has the un-set stack
Reviewed-by: shade, kevinw, stefank
1 parent bfdeb33 commit 31858fc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: src/hotspot/share/runtime/thread.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ Thread::Thread(MemTag mem_tag) {
145145
MACOS_AARCH64_ONLY(DEBUG_ONLY(_wx_init = false));
146146
}
147147

148+
#ifdef ASSERT
149+
address Thread::stack_base() const {
150+
// Note: can't report Thread::name() here as that can require a ResourceMark which we
151+
// can't use because this gets called too early in the thread initialization.
152+
assert(_stack_base != nullptr, "Stack base not yet set for thread id:%d (0 if not set)",
153+
osthread() != nullptr ? osthread()->thread_id() : 0);
154+
return _stack_base;
155+
}
156+
#endif
157+
148158
void Thread::initialize_tlab() {
149159
if (UseTLAB) {
150160
tlab().initialize();

Diff for: src/hotspot/share/runtime/thread.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class Thread: public ThreadShadow {
532532

533533
public:
534534
// Stack overflow support
535-
address stack_base() const { assert(_stack_base != nullptr,"Sanity check"); return _stack_base; }
535+
address stack_base() const DEBUG_ONLY(;) NOT_DEBUG({ return _stack_base; })
536536
void set_stack_base(address base) { _stack_base = base; }
537537
size_t stack_size() const { return _stack_size; }
538538
void set_stack_size(size_t size) { _stack_size = size; }

0 commit comments

Comments
 (0)