8239895: assert(_stack_base != 0LL) failed: Sanity check

Reviewed-by: dcubed, stuefe
This commit is contained in:
David Holmes 2020-04-02 19:13:27 -04:00
parent 80b8644499
commit cf22d4440a
9 changed files with 22 additions and 15 deletions

View File

@ -76,14 +76,14 @@ bool frame::safe_for_sender(JavaThread *thread) {
// So unextended sp must be within the stack but we need not to check
// that unextended sp >= sp
if (!thread->is_in_full_stack(unextended_sp)) {
if (!thread->is_in_full_stack_checked(unextended_sp)) {
return false;
}
// an fp must be within the stack and above (but not equal) sp
// second evaluation on fp+ is added to handle situation where fp is -1
bool fp_safe = thread->is_in_stack_range_excl(fp, sp) &&
thread->is_in_full_stack(fp + (return_addr_offset * sizeof(void*)));
thread->is_in_full_stack_checked(fp + (return_addr_offset * sizeof(void*)));
// We know sp/unextended_sp are safe only fp is questionable here
@ -145,7 +145,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
sender_sp = _unextended_sp + _cb->frame_size();
// Is sender_sp safe?
if (!thread->is_in_full_stack((address)sender_sp)) {
if (!thread->is_in_full_stack_checked((address)sender_sp)) {
return false;
}
sender_unextended_sp = sender_sp;

View File

@ -113,7 +113,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
sender_sp = _unextended_sp + _cb->frame_size();
// Is sender_sp safe?
if (!thread->is_in_full_stack((address)sender_sp)) {
if (!thread->is_in_full_stack_checked((address)sender_sp)) {
return false;
}
// With our calling conventions, the return_address should

View File

@ -62,7 +62,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
}
// Unextended sp must be within the stack
if (!thread->is_in_full_stack(unextended_sp)) {
if (!thread->is_in_full_stack_checked(unextended_sp)) {
return false;
}

View File

@ -66,7 +66,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
}
// Unextended sp must be within the stack
if (!thread->is_in_full_stack(unextended_sp)) {
if (!thread->is_in_full_stack_checked(unextended_sp)) {
return false;
}

View File

@ -70,7 +70,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
// an fp must be within the stack and above (but not equal) sp
// second evaluation on fp+ is added to handle situation where fp is -1
bool fp_safe = thread->is_in_stack_range_excl(fp, sp) &&
thread->is_in_full_stack(fp + (return_addr_offset * sizeof(void*)));
thread->is_in_full_stack_checked(fp + (return_addr_offset * sizeof(void*)));
// We know sp/unextended_sp are safe only fp is questionable here
@ -132,7 +132,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
sender_sp = _unextended_sp + _cb->frame_size();
// Is sender_sp safe?
if (!thread->is_in_full_stack((address)sender_sp)) {
if (!thread->is_in_full_stack_checked((address)sender_sp)) {
return false;
}
sender_unextended_sp = sender_sp;

View File

@ -121,12 +121,12 @@ bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const
}
if (thread->is_Java_thread()) {
if (!thread->is_in_full_stack((address)suspect)) {
if (!thread->is_in_full_stack_checked((address)suspect)) {
DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");)
return false;
}
address _sp = (address)((intptr_t)suspect->uc_mcontext.gregs[REG_SP] + STACK_BIAS);
if (!thread->is_in_full_stack(_sp) ||
if (!thread->is_in_full_stack_checked(_sp) ||
!frame::is_valid_stack_pointer(((JavaThread*)thread)->base_of_stack_pointer(), (intptr_t*)_sp)) {
DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");)
return false;

View File

@ -141,11 +141,11 @@ bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const
}
if (thread->is_Java_thread()) {
if (!thread->is_in_full_stack((address)suspect)) {
if (!thread->is_in_full_stack_checked((address)suspect)) {
DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");)
return false;
}
if (!thread->is_in_full_stack((address) suspect->uc_mcontext.gregs[REG_SP])) {
if (!thread->is_in_full_stack_checked((address) suspect->uc_mcontext.gregs[REG_SP])) {
DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");)
return false;
}

View File

@ -349,7 +349,6 @@ void Thread::record_stack_base_and_size() {
// If possible, refrain from doing anything which may crash or assert since
// quite probably those crash dumps will be useless.
set_stack_base(os::current_stack_base());
assert(_stack_base != NULL, "current_stack_base failed for %s", name());
set_stack_size(os::current_stack_size());
#ifdef SOLARIS

View File

@ -711,10 +711,18 @@ class Thread: public ThreadShadow {
// Check if address is in the stack mapped to this thread. Used mainly in
// error reporting (so has to include guard zone) and frame printing.
bool is_in_full_stack(address adr) const {
// Expects _stack_base to be initialized - checked with assert.
bool is_in_full_stack_checked(address adr) const {
return is_in_stack_range_incl(adr, stack_end());
}
// Like is_in_full_stack_checked but without the assertions as this
// may be called in a thread before _stack_base is initialized.
bool is_in_full_stack(address adr) const {
address stack_end = _stack_base - _stack_size;
return _stack_base > adr && adr >= stack_end;
}
// Check if address is in the live stack of this thread (not just for locks).
// Warning: can only be called by the current thread on itself.
bool is_in_live_stack(address adr) const {
@ -748,7 +756,7 @@ protected:
public:
// Stack overflow support
address stack_base() const { assert(_stack_base != NULL,"Sanity check failed for %s", name()); return _stack_base; }
address stack_base() const { assert(_stack_base != NULL,"Sanity check"); 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; }