From 27cfcef99f1acae1ba0beb49d01acbc47154a54b Mon Sep 17 00:00:00 2001 From: David Holmes Date: Fri, 5 Apr 2024 00:29:06 +0000 Subject: [PATCH] 8329651: TestLibGraal.java crashes with assert(_stack_base != nullptr) Reviewed-by: stefank, dcubed --- src/hotspot/share/runtime/thread.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index 7401629bf94..e29e419e9f1 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -491,9 +491,11 @@ void Thread::print_on_error(outputStream* st, char* buf, int buflen) const { if (os_thr != nullptr) { st->fill_to(67); if (os_thr->get_state() != ZOMBIE) { + // Use raw field members for stack base/size as this could be + // called before a thread has run enough to initialize them. st->print(" [id=%d, stack(" PTR_FORMAT "," PTR_FORMAT ") (" PROPERFMT ")]", - osthread()->thread_id(), p2i(stack_end()), p2i(stack_base()), - PROPERFMTARGS(stack_size())); + osthread()->thread_id(), p2i(_stack_base - _stack_size), p2i(_stack_base), + PROPERFMTARGS(_stack_size)); } else { st->print(" terminated"); }