Subject: Re: threaded applications randomly crash on -current
To: Nicolas Joly <njoly@pasteur.fr>
From: Frank van der Linden <fvdl@netbsd.org>
List: port-amd64
Date: 10/20/2004 17:17:28
--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, Oct 20, 2004 at 04:54:08PM +0200, Nicolas Joly wrote:
> While trying some bioinfo applications on our amd64 machines running
> 2.99.10 and 2.0H kernels (we currently run them on Tru64/alpha), i
> noticed that the threaded ones randomly crash (at least NCBI blast and
> WashU hmmer).
>
> In the meantime, they run flawlessly on other systems i tested, under
> the same conditions: NetBSD/i386 2.99.10, NetBSD/alpha 2.99.10,
> Linux/amd64 CentOS-3.3RC1 and Tru64/alpha v5.1.
Hi Nicolas,
I have some pthread fixes sitting in my mailbox.. have not had a chance
to give them a final lookover, but I suspect that you may be seeing
this issue.
Wolfgang Solfrank came up with this patch, I'll attach it so that you
can test it.
- Frank
--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diffs
Index: sys/arch/amd64/include/mcontext.h
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/include/mcontext.h,v
retrieving revision 1.4
diff -u -r1.4 mcontext.h
--- sys/arch/amd64/include/mcontext.h 13 Oct 2003 18:38:34 -0000 1.4
+++ sys/arch/amd64/include/mcontext.h 4 Oct 2004 08:34:31 -0000
@@ -95,7 +95,7 @@
#define _UC_UCONTEXT_ALIGN (~0xf)
-#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_URSP])
+#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_URSP] - 128)
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_RIP])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RAX])
Index: lib/libpthread/arch/x86_64/_context_u.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/x86_64/_context_u.S,v
retrieving revision 1.3
diff -u -r1.3 _context_u.S
--- lib/libpthread/arch/x86_64/_context_u.S 8 Nov 2003 21:45:59 -0000 1.3
+++ lib/libpthread/arch/x86_64/_context_u.S 4 Oct 2004 08:34:31 -0000
@@ -53,6 +53,11 @@
fxsave UC_FPREGS(%rdi) ; \
movl $(_UC_USER | _UC_CPU | _UC_FPU),UC_FLAGS(%rdi)
+#define lretqm(x) \
+ .byte 0x48 ; \
+ .byte 0xca ; \
+ .word x
+
#define SETC \
movl UC_FLAGS(%rdi), %eax ; \
btl $_UC_USER_BIT, %eax ; \
@@ -91,28 +96,28 @@
movq (UC_REGS + _REG_RDX * 8)(%rdi), %rdx ; \
movq (UC_REGS + _REG_RSI * 8)(%rdi), %rsi ; \
movw (UC_REGS + _REG_CS * 8)(%rdi), %ax ; \
- movq %rax, -8(%r11) ; \
+ movq %rax, -128-8(%r11) ; \
movw (UC_REGS + _REG_DS * 8)(%rdi), %ax ; \
- movq %rax, -32(%r11) ; \
+ movq %rax, -128-32(%r11) ; \
movq (UC_REGS + _REG_RIP * 8)(%rdi), %rax ; \
- movq %rax, -16(%r11) ; \
+ movq %rax, -128-16(%r11) ; \
movq (UC_REGS + _REG_RAX * 8)(%rdi), %rax ; \
- movq %rax, -24(%r11) ; \
+ movq %rax, -128-24(%r11) ; \
movq (UC_REGS + _REG_R11 * 8)(%rdi), %rax ; \
- movq %rax, -40(%r11) ; \
+ movq %rax, -128-40(%r11) ; \
movq (UC_REGS + _REG_RFL * 8)(%rdi), %rax ; \
- movq %rax, -48(%r11) ; \
+ movq %rax, -128-48(%r11) ; \
; \
movw (UC_REGS + _REG_SS * 8)(%rdi), %ss ; \
movq (UC_REGS + _REG_RDI)(%rdi), %rdi ; \
- leaq -48(%r11), %rsp ; \
+ leaq -128-48(%r11), %rsp ; \
; \
popfq ; \
popq %r11 ; \
popq %rax ; \
movl %eax,%ds ; \
popq %rax ; \
- lretq
+ lretqm(128)
ENTRY(_getcontext_u)
GETC
--liOOAslEiF7prFVr--