# HG changeset patch # User mdoerr # Date 1571927331 -7200 # Node ID 7ab0ec5357763c0024e3a153ce686f936d0987b6 # Parent e5a0eb0db9e1f4b515fc3453104a1cecc70df841 8231949: [PPC64, s390]: Make async profiling more reliable Summary: Better checks if method from interpreter frame is valid. Reviewed-by: rrich, ghaug, goetz diff -r e5a0eb0db9e1 -r 7ab0ec535776 src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp --- a/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp Fri Jun 12 14:33:20 2020 -0700 +++ b/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp Thu Oct 24 16:28:51 2019 +0200 @@ -51,21 +51,22 @@ } if (ret_frame.is_interpreted_frame()) { - frame::ijava_state* istate = ret_frame.get_ijava_state(); - if (!((Method*)(istate->method))->is_metaspace_object()) { - return false; - } - uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/]; - uint64_t istate_bcp = istate->bcp; - uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base()); - uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size()); - if (istate_bcp >= code_start && istate_bcp < code_end) { - // we have a valid bcp, don't touch it, do nothing - } else if (reg_bcp >= code_start && reg_bcp < code_end) { - istate->bcp = reg_bcp; + frame::ijava_state *istate = ret_frame.get_ijava_state(); + const Method *m = (const Method*)(istate->method); + if (m == NULL || !m->is_valid_method()) return false; + if (!Metaspace::contains((const void*)m)) return false; + + uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/]; + uint64_t istate_bcp = istate->bcp; + uint64_t code_start = (uint64_t)(m->code_base()); + uint64_t code_end = (uint64_t)(m->code_base() + m->code_size()); + if (istate_bcp >= code_start && istate_bcp < code_end) { + // we have a valid bcp, don't touch it, do nothing + } else if (reg_bcp >= code_start && reg_bcp < code_end) { + istate->bcp = reg_bcp; } else { - return false; - } + return false; + } } if (!ret_frame.safe_for_sender(this)) { // nothing else to try if the frame isn't good