mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-13 05:10:07 +08:00
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:
parent
2e798523e4
commit
9b2329f66c
4
tccrun.c
4
tccrun.c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user