From owner-freebsd-bugs Sun Mar 8 17:50:07 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA19157 for freebsd-bugs-outgoing; Sun, 8 Mar 1998 17:50:07 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA19137; Sun, 8 Mar 1998 17:50:03 -0800 (PST) (envelope-from gnats) Received: from sunny.bog.msu.su (sunny.bog.msu.su [158.250.20.1]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA18204 for ; Sun, 8 Mar 1998 17:44:55 -0800 (PST) (envelope-from dima@bog.msu.su) Received: from localhost (dima@localhost) by sunny.bog.msu.su (8.8.8/8.8.8) with SMTP id EAA05707 for ; Mon, 9 Mar 1998 04:44:40 +0300 (MSK) (envelope-from dima@bog.msu.su) Message-Id: Date: Mon, 9 Mar 1998 04:44:39 +0300 (MSK) From: Dmitry Khrustalev To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/5953: setjmp wrapper in libc_r is broken Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 5953 >Category: bin >Synopsis: setjmp wrapper in libc_r is broken >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 8 17:50:01 PST 1998 >Last-Modified: >Originator: Dmitry Khrustalev >Organization: >Release: FreeBSD 3.0-CURRENT i386 >Environment: FreeBSD 3.0-CURRENT i386, using cc -pthread >Description: environment saved by setjmp wrapper in lib/libc_r/uthread/uthread_setjmp.c is invalid after return from wrapper. >How-To-Repeat: this example will crash when compiled using cc -pthread: #include jmp_buf jb; main () { setjmp(jb); longjmp(jb, 0); } >Fix: do not wrap setjmp and longjmp, do not rename setjmp/longjmp/ sigsetjmp/siglongjmp then building libc_r. rm lib/libc_r/uthread/uthread_setjmp.c rm lib/libc_r/uthread/uthread_longjmp.c diff -u -r lib.ORIG/libc/i386/gen/setjmp.S lib/libc/i386/gen/setjmp.S --- lib.ORIG/libc/i386/gen/setjmp.S Mon Mar 9 04:28:38 1998 +++ lib/libc/i386/gen/setjmp.S Mon Mar 9 04:20:30 1998 @@ -54,11 +54,7 @@ #include "DEFS.h" #include "SYS.h" -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_setjmp) -#else ENTRY(setjmp) -#endif PIC_PROLOGUE pushl $0 #ifdef _THREAD_SAFE @@ -81,11 +77,7 @@ xorl %eax,%eax ret -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_longjmp) -#else ENTRY(longjmp) -#endif movl 4(%esp),%edx PIC_PROLOGUE pushl 24(%edx) diff -u -r lib.ORIG/libc/i386/gen/sigsetjmp.S lib/libc/i386/gen/sigsetjmp.S --- lib.ORIG/libc/i386/gen/sigsetjmp.S Mon Mar 9 04:28:47 1998 +++ lib/libc/i386/gen/sigsetjmp.S Mon Mar 9 04:21:46 1998 @@ -59,11 +59,7 @@ * use sigreturn() if sigreturn() works. */ -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_sigsetjmp) -#else ENTRY(sigsetjmp) -#endif movl 8(%esp),%eax movl 4(%esp),%ecx movl %eax,32(%ecx) @@ -91,11 +87,7 @@ xorl %eax,%eax ret -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_siglongjmp) -#else ENTRY(siglongjmp) -#endif movl 4(%esp),%edx cmpl $0,32(%edx) jz 2f diff -u -r lib.ORIG/libc_r/uthread/Makefile.inc lib/libc_r/uthread/Makefile.inc --- lib.ORIG/libc_r/uthread/Makefile.inc Mon Mar 9 04:27:47 1998 +++ lib/libc_r/uthread/Makefile.inc Mon Mar 9 04:30:27 1998 @@ -51,7 +51,6 @@ uthread_kern.c \ uthread_kill.c \ uthread_listen.c \ - uthread_longjmp.c \ uthread_mattr_init.c \ uthread_mattr_kind_np.c \ uthread_multi_np.c \ @@ -70,7 +69,6 @@ uthread_self.c \ uthread_sendto.c \ uthread_seterrno.c \ - uthread_setjmp.c \ uthread_setprio.c \ uthread_setsockopt.c \ uthread_shutdown.c \ diff -u -r lib.ORIG/libc_r/uthread/uthread_create.c lib/libc_r/uthread/uthread_create.c --- lib.ORIG/libc_r/uthread/uthread_create.c Mon Mar 9 04:27:45 1998 +++ lib/libc_r/uthread/uthread_create.c Mon Mar 9 04:34:42 1998 @@ -107,7 +107,7 @@ } /* Initialise the jump buffer: */ - _thread_sys_setjmp(new_thread->saved_jmp_buf); + setjmp(new_thread->saved_jmp_buf); /* * Set up new stack frame so that it looks like it diff -u -r lib.ORIG/libc_r/uthread/uthread_kern.c lib/libc_r/uthread/uthread_kern.c --- lib.ORIG/libc_r/uthread/uthread_kern.c Mon Mar 9 04:27:46 1998 +++ lib/libc_r/uthread/uthread_kern.c Mon Mar 9 04:34:19 1998 @@ -101,7 +101,7 @@ _thread_run->sig_saved = 1; } /* Save the state of the current thread: */ - else if (_thread_sys_setjmp(_thread_run->saved_jmp_buf) != 0) { + else if (setjmp(_thread_run->saved_jmp_buf) != 0) { /* Unblock signals (just in case): */ _thread_kern_sig_unblock(0); @@ -810,7 +810,7 @@ * was context switched out (by a longjmp to * a different thread): */ - _thread_sys_longjmp(_thread_run->saved_jmp_buf, 1); + longjmp(_thread_run->saved_jmp_buf, 1); } /* This point should not be reached. */ >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message