riscv64: Work around qemu bug

old qemu (before april 2020) have a bug in the layout of
struct ucontext, so we get invalid values under qemu-userspace emulation
when inspecting the signal context.  Try to recognize this and
graciously error out instead of segfaulting in the backtracer routines.
This commit is contained in:
Michael Matz 2020-07-15 23:11:42 +02:00
parent 2e798523e4
commit 9b2329f66c

View File

@ -843,8 +843,10 @@ static int rt_get_caller_pc(addr_t *paddr, rt_context *rc, int level)
*paddr = rc->ip;
} else {
addr_t *fp = (addr_t*)rc->fp;
while (--level)
while (--level && fp >= (addr_t*)0x1000)
fp = (addr_t *)fp[-2];
if (fp < (addr_t*)0x1000)
return -1;
*paddr = fp[-1];
}
return 0;