amd64/162214: longjmp and siglongjmp, stack pointer is not aligned

yamayan yamayan at kbh.biglobe.ne.jp
Tue Nov 1 07:50:11 UTC 2011


>Number:         162214
>Category:       amd64
>Synopsis:       longjmp and siglongjmp, stack pointer is not aligned
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-amd64
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 01 07:50:11 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     yamayan
>Release:        10.0-CURRENT
>Organization:
>Environment:
FreeBSD yamayan 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r226954M: Mon Oct 31 10:10:55 JST 2011     root at yamayan:/usr/obj/usr/src/sys/YAMAYAN  amd64

>Description:
/usr/src/lib/libc/amd64/gen/
At longjmp(setjmp.S) and siglongjmp(sigsetjmp.S),
stack pointer is not 16-byte alignment,
so to call sigprocmask makes BusError.

in /usr/src/lib/libthr/thread/thr_sig.c,
compile with clang -march=native @ corei7,
movaps is used at sigprocmask.

It is not problem.
unaligned stack pointer is problem.
>How-To-Repeat:
build and install lib/libthr with clang -march=corei7
(-march=native @ corei7 CPU)

for example, build /usr/ports/lang/perl5.14.
miniperl stops with BusError.

check corefile.
>Fix:
patch my patch.
Adjust stack pointer alignment.

Patch attached with submission follows:

Index: setjmp.S
===================================================================
--- setjmp.S	(revision 226979)
+++ setjmp.S	(working copy)
@@ -81,7 +81,9 @@
 	movq	$3,%rdi			/* SIG_SETMASK     */
 	leaq	72(%rdx),%rsi		/* (sigset_t*)set  */
 	movq	$0,%rdx			/* (sigset_t*)oset */
+	subq	$0x8,%rsp	/* adjust alignment */
 	call	PIC_PLT(CNAME(_sigprocmask))
+	addq	$0x8,%rsp
 	popq	%rsi
 	popq	%rdi			/* jmpbuf */
 	movq	%rdi,%rdx
Index: sigsetjmp.S
===================================================================
--- sigsetjmp.S	(revision 226979)
+++ sigsetjmp.S	(working copy)
@@ -90,7 +90,9 @@
 	movq	$3,%rdi			/* SIG_SETMASK     */
 	leaq	72(%rdx),%rsi		/* (sigset_t*)set  */
 	movq	$0,%rdx			/* (sigset_t*)oset */
+	subq	$0x8,%rsp	/* adjust alignment */
 	call	PIC_PLT(CNAME(_sigprocmask))
+	addq	$0x8,%rsp
 	popq	%rsi
 	popq	%rdi			/* jmpbuf */
 2:	movq	%rdi,%rdx


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-amd64 mailing list