[RFC PATCH] LoongArch: Fix intermittent nptl/tst-cancel32 failure
mengqinggang
mengqinggang@loongson.cn
Tue Aug 4 13:05:32 GMT 2026
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
More information about the Libc-alpha
mailing list