Subject: port-sparc/2180: _{set,long}jmp(3) assumes 8-byte alignment
To: None <gnats-bugs@NetBSD.ORG>
From: Michael Eriksson T/N <Michael.Eriksson@era-t.ericsson.se>
List: netbsd-bugs
Date: 03/06/1996 11:54:16
>Number: 2180
>Category: port-sparc
>Synopsis: _{set,long}jmp(3) assumes 8-byte alignment
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 6 06:20:07 1996
>Last-Modified:
>Originator: Michael Eriksson T/N
>Organization:
>Release: 1.1
>Environment:
System: NetBSD abro 1.1 NetBSD 1.1 (MAVERICK) #0: Tue Dec 19 08:52:19 MET 1995 eramer@abro:/usr/src/sys/arch/sparc/compile/MAVERICK sparc
Sun IPX running vanilla NetBSD 1.1.
>Description:
_setjmp(3) and _longjmp(3) use machine instructions std and ldd,
respectively, which assume that the jmp_buf is 8-byte aligned.
>How-To-Repeat:
Run the program below, and watch it crash with SIGBUS.
#include <setjmp.h>
struct {
int i;
jmp_buf env;
} foo;
main()
{
_setjmp(foo.env);
}
>Fix:
*** _setjmp.S.orig Sat Oct 14 01:44:06 1995
--- _setjmp.S Wed Mar 6 10:12:19 1996
***************
*** 56,63 ****
#include "DEFS.h"
ENTRY(_setjmp)
! std %sp, [%o0+0] /* caller's stack pointer and return pc */
! st %fp, [%o0+8] /* store caller's frame pointer */
retl
clr %o0 ! return 0
--- 56,64 ----
#include "DEFS.h"
ENTRY(_setjmp)
! st %sp, [%o0+0] /* caller's stack pointer */
! st %o7, [%o0+4] /* ...return pc */
! st %fp, [%o0+8] /* ...frame pointer */
retl
clr %o0 ! return 0
***************
*** 73,79 ****
bl,a 1b ! if below,
restore ! pop frame and loop
be,a 2f ! if there,
! ldd [%g1+0], %o2 ! fetch return %sp and pc, and get out
Lbotch:
call _longjmperror ! otherwise, went too far; bomb out
--- 74,80 ----
bl,a 1b ! if below,
restore ! pop frame and loop
be,a 2f ! if there,
! ld [%g1+0], %o2 ! fetch return %sp, and get out
Lbotch:
call _longjmperror ! otherwise, went too far; bomb out
***************
*** 86,90 ****
--- 87,92 ----
mov %o2, %sp ! it is OK, put it in place
b,a Lbotch
3:
+ ld [%g1+4], %o3 ! fetch pc
jmp %o3 + 8 ! success, return %g6
mov %g6, %o0
>Audit-Trail:
>Unformatted: