Subject: port-m68k/385: setjmp()/longjmp() do not work in dynamic m68k binaries
To: None <gnats-admin>
From: jason downs <downsj@CSOS.ORST.EDU>
List: netbsd-bugs
Date: 08/03/1994 02:20:06
>Number:         385
>Category:       port-m68k
>Synopsis:       setjmp()/longjmp() do not work in dynamic m68k binaries
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug  3 02:20:04 1994
>Originator:     jason downs
>Organization:
Computer Science Outreach Services, Oregon State University
>Release:        NetBSD 1.0-ALPHA
>Environment:
	
System: NetBSD nemesis 1.0-ALPHA NetBSD 1.0-ALPHA (NEMESIS) #15: Wed Aug 3 00:06:54 PDT 1994 root@nemesis:/tmp_mnt/jadzia/info/BSD/src/sys/arch/hp300/compile/NEMESIS hp300


>Description:
	As discussed before, longjmp() specifically fails the first time it
	is called within a dynamic binary. [See port-hp300 archive.]

	This is a severe bug, and should be fixed for 1.0
>How-To-Repeat:
	As discussed before, using setjmp()/longjmp() in a dynamic binary
	will produce unexpected return values from setjmp(), when longjmp()
	called. [See port-hp300 archive.]
>Fix:
	'inlining' sigreturn() inside of longjmp() is the easiest and
	smallest form of at least bypassing this problem.

	This fix may very well NOT be the 'proper' way to fix the problem,
	but it at least avoids a major potential pitfall for all m68k ports.

*** setjmp.S.orig	Tue Aug  2 03:14:35 1994
--- setjmp.S	Tue Aug  2 23:13:28 1994
***************
*** 86,93 ****
--- 86,98 ----
  	moveq	#1,d0		/* else make non-zero */
  ok:
  	moveml	a0@(28),#0x3CFC	/* restore non-scratch regs */
+ #if 1
+         trap    #1              /* signals sigreturn() */
+         jra     cerror
+ #else
  	movl	a0,sp@-		/* let sigreturn */
  	jbsr	_sigreturn	/*   finish for us */
+ #endif
  
  botch:
  	jbsr	_longjmperror
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------