possible bug in newlib-1.18.0/newlib/libc/machine/i386/setjmp.S

Andrew Makhorin mao@gnu.org
Fri Nov 5 14:09:00 GMT 2010


Hello,

I think that I found a bug in
newlib-1.18.0/newlib/libc/machine/i386/setjmp.S .
Namely, if longjmp is called with zero val (second argument), it causes
setjmp to return 0 rather than 1.

Probably the bug can be fixed as follows:

SYM (longjmp):
	pushl	ebp
	movl	esp,ebp

	movl	8(ebp),edi	/* get jmp_buf */
	movl	12(ebp),eax	/* store retval in j->eax */
+       test    eax,eax
+       jnz     skip
+       inc     eax             /* if eax = 0 then eax := 1 */
+skip:
	movl	eax,0(edi)
. . .

Thank you,

Andrew Makhorin



More information about the Newlib mailing list