diff options
author | Raphael Moreira Zinsly <rzinsly@linux.ibm.com> | 2021-11-11 11:40:10 -0300 |
---|---|---|
committer | Segher Boessenkool <segher@kernel.crashing.org> | 2021-11-11 15:29:25 +0000 |
commit | 8d71d3a317236ab4a69f441cf867a43aeb448150 (patch) | |
tree | 2faac06ced47961dc0f913bdac9cab9d91992537 /libgcc/config | |
parent | 8d3abf42d5c2ccd5c5e879088fdf6e071c3d1b9e (diff) | |
download | gcc-8d71d3a317236ab4a69f441cf867a43aeb448150.zip gcc-8d71d3a317236ab4a69f441cf867a43aeb448150.tar.gz gcc-8d71d3a317236ab4a69f441cf867a43aeb448150.tar.bz2 |
libgcc: Fix backtrace fallback on PowerPC Big-endian
At the end of the backtrace stream _Unwind_Find_FDE() may not be able
to find the frame unwind info and will later call the backtrace fallback
instead of finishing. This occurs when using an old libc on ppc64 due to
dl_iterate_phdr() not being able to set the fde in the last trace.
When this occurs the cfa of the trace will be behind of context's cfa.
Also, libgo’s probestackmaps() calls the backtrace with a null pointer
and can get to the backchain fallback with the same problem, in this case
we are only interested in find a stack map, we don't need nor can do a
backchain.
_Unwind_ForcedUnwind_Phase2() can hit the same issue as it uses
uw_frame_state_for(), so we need to treat _URC_NORMAL_STOP.
libgcc/ChangeLog:
PR libgcc/103044
* config/rs6000/linux-unwind.h (ppc_backchain_fallback): Check if it's
called with a null argument or at the end of the backtrace and return.
* unwind.inc (_Unwind_ForcedUnwind_Phase2): Treat _URC_NORMAL_STOP.
Diffstat (limited to 'libgcc/config')
-rw-r--r-- | libgcc/config/rs6000/linux-unwind.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libgcc/config/rs6000/linux-unwind.h b/libgcc/config/rs6000/linux-unwind.h index 4788497..5ef9c1a 100644 --- a/libgcc/config/rs6000/linux-unwind.h +++ b/libgcc/config/rs6000/linux-unwind.h @@ -402,8 +402,14 @@ ppc_backchain_fallback (struct _Unwind_Context *context, void *a) struct trace_arg *arg = a; int count; - /* Get the last address computed and start with the next. */ + /* Get the last address computed. */ current = context->cfa; + + /* If the trace CFA is not the context CFA the backtrace is done. */ + if (arg == NULL || arg->cfa != current) + return; + + /* Start with next address. */ current = current->backchain; for (count = arg->count; current != NULL; current = current->backchain) |