public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/grte] sparc32: Add nop before __startcontext to stop unwinding [BZ #22919]
@ 2021-08-27 23:26 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-08-27 23:26 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4d1ae634e6b4a1ea65c4ab10f2988ffde7476e55

commit 4d1ae634e6b4a1ea65c4ab10f2988ffde7476e55
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Fri Mar 9 00:14:27 2018 +0100

    sparc32: Add nop before __startcontext to stop unwinding [BZ #22919]
    
    On sparc32 tst-makecontext fails, as backtrace called within a context
    created by makecontext to yield infinite backtrace.
    
    Fix that the same way than nios2 by adding a nop just before
    __startcontext. This is needed as otherwise FDE lookup just repeatedly
    finds __setcontext's FDE in an infinite loop, due to the convention of
    using 'address - 1' for FDE lookup.
    
    Changelog:
            [BZ #22919]
            * sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S (__startcontext):
            Add nop before __startcontext, add explaining comments.
    
    (cherry picked from commit 9aa5c222b9e0409143410a02b6364a3b25dbf028)

Diff:
---
 ChangeLog                                          |  6 ++++++
 sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 494f98b51b..3ae0ecd07a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-09  Aurelien Jarno  <aurelien@aurel32.net>
+
+	[BZ #22919]
+	* sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S (__startcontext):
+	Add nop before __startcontext, add explaining comments.
+
 2018-03-07  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
 	[BZ #22926]
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S b/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S
index 695f172c63..283aef1b30 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S
@@ -95,6 +95,19 @@ END(__setcontext)
 
 weak_alias (__setcontext, setcontext)
 
+/* We add an NOP here to separate between __setcontext/__startcontext. The
+   wanted behavior that happens is: when unwinding from a function called
+   inside a makecontext() context, FDE lookup will use '&__startcontext - 1',
+   then returns NULL for no FDE found, and immediately ends the unwind, in
+   a normal fashion.
+
+   If this NOP word does not exist, FDE lookup just repeatedly finds
+   __setcontext's FDE in an infinite loop, due to the convention of using
+   'address - 1' for FDE lookup. Modifiying/deleting the below
+   __startcontext's FDE has no help on this.  */
+
+	nop
+
 /* This is the helper code which gets called if a function which is
    registered with 'makecontext' returns.  In this case we have to
    install the context listed in the uc_link element of the context


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-27 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 23:26 [glibc/maskray/grte] sparc32: Add nop before __startcontext to stop unwinding [BZ #22919] Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).