public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: mengqinggang <mengqinggang@loongson.cn>
To: libc-alpha@sourceware.org
Cc: adhemerval.zanella@linaro.org, xuchenghua@loongson.cn,
	caiyinyu@loongson.cn, chenglulu@loongson.cn, xry111@xry111.site,
	i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn,
	hejinyang@loongson.cn, mengqinggang@loongson.cn
Subject: [RFC PATCH] LoongArch: Fix intermittent nptl/tst-cancel32 failure
Date: Tue,  4 Aug 2026 21:05:32 +0800	[thread overview]
Message-ID: <20260804130533.594873-1-mengqinggang@loongson.cn> (raw)

The nptl/tst-cancel32 test fails intermittently on LoongArch
with SIGSEGV at __longjmp:

0x7ffff7de7f6c <__longjmp+28>   rotri.d         $sp, $t0, 0x11
0x7ffff7de7f70 <__longjmp+32>   xor             $sp, $sp, $t1

If the thread is cancelled between the rotri.d and xor,
an incomplete sp register causes the SIGSEGV.

Add a temporary register to avoid this issue.
---
 sysdeps/loongarch/__longjmp.S                         |  4 ++--
 sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S
index 191f03320a..302cb6894a 100644
--- a/sysdeps/loongarch/__longjmp.S
+++ b/sysdeps/loongarch/__longjmp.S
@@ -23,9 +23,9 @@
 ENTRY (__longjmp)
 #ifdef PTR_MANGLE
 	REG_L t0, a0, 0*SZREG
-	PTR_DEMANGLE (ra, t0, t1)
+	PTR_DEMANGLE (ra, t0, t1, t2)
 	REG_L t0, a0, 1*SZREG
-	PTR_DEMANGLE2 (sp, t0, t1)
+	PTR_DEMANGLE2 (sp, t0, t1, t2)
 #else
 	REG_L ra, a0, 0*SZREG
 	REG_L sp, a0, 1*SZREG
diff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h
index 75498545cb..8fe7d1e15a 100644
--- a/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h
+++ b/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h
@@ -32,16 +32,16 @@
 # define PTR_MANGLE(dst, src, guard) \
   PTR_MANGLE_LOAD (guard); \
   PTR_MANGLE2 (dst, src, guard);
-# define PTR_DEMANGLE(dst, src, guard) \
+# define PTR_DEMANGLE(dst, src, guard, tmp) \
   PTR_MANGLE_LOAD (guard); \
-  PTR_DEMANGLE2 (dst, src, guard);
+  PTR_DEMANGLE2 (dst, src, guard, tmp);
 /* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
 # define PTR_MANGLE2(dst, src, guard) \
   xor  dst, src, guard; \
   rotri.d  dst, dst, 47;
-# define PTR_DEMANGLE2(dst, src, guard) \
-  rotri.d  dst, src, 17; \
-  xor  dst, dst, guard;
+# define PTR_DEMANGLE2(dst, src, guard, tmp) \
+  rotri.d  tmp, src, 17; \
+  xor  dst, tmp, guard;
 #endif
 
 #endif /* POINTER_GUARD_ASM_H */
-- 
2.34.1


             reply	other threads:[~2026-08-04 13:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 13:05 mengqinggang [this message]
2026-08-04 13:50 Wilco Dijkstra
2026-08-05  2:09 ` mengqinggang
2026-08-05  3:33   ` Xi Ruoyao
2026-08-05  3:47     ` mengqinggang
2026-08-05  3:53       ` Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260804130533.594873-1-mengqinggang@loongson.cn \
    --to=mengqinggang@loongson.cn \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=chenglulu@loongson.cn \
    --cc=hejinyang@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=libc-alpha@sourceware.org \
    --cc=luweining@loongson.cn \
    --cc=maskray@google.com \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).