Thanks! I'll try it as soon as possible (I don't have a -stable machine ready, and I'd 
rather not try my first "make world"
attempts on my production machine...)

Louis-Philippe Gagnon

----- Original Message -----
From: "Daniel Eischen" <[EMAIL PROTECTED]>
To: "Louis-Philippe Gagnon" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 2001 5:08 PM
Subject: Re: pthread/longjmp/signal problem


> On Thu, 21 Jun 2001, Louis-Philippe Gagnon wrote:
> > No reactions the first time, let's try again.
> >
> > I've encountered a problem in the interaction betwen signals, longjmp and
> > pthreads; I'm hoping someone can help me make sense of it.
> >
> > I've been trying to implement a IsBadReadPtr-style function in FreeBSD by
> > using signal handlers and longjmp/setjmp. It seemed to work as expected,
> > until I started using the -pthread option to gcc (thus linking against
> > libc_r). Now the function only works on the first call; subsequent calls
> > hang on the segmentation fault.
> >
> > Here's an example of the kind of code that causes problems :
>
> Try this patch (to -stable).  Only the patch to uthread_sig.c is
> needed for -current.
>
> --
> Dan Eischen
>
>
> Index: libc/i386/gen/setjmp.S
> ===================================================================
> RCS file: /opt/FreeBSD/cvs/src/lib/libc/i386/gen/setjmp.S,v
> retrieving revision 1.17.2.1
> diff -u -r1.17.2.1 setjmp.S
> --- libc/i386/gen/setjmp.S 2000/05/16 20:43:21 1.17.2.1
> +++ libc/i386/gen/setjmp.S 2001/06/26 21:07:23
> @@ -61,11 +61,7 @@
>   pushl %eax /* (sigset_t*)oset */
>   pushl $0 /* (sigset_t*)set  */
>   pushl $1 /* SIG_BLOCK       */
> -#ifdef _THREAD_SAFE
> - call PIC_PLT(CNAME(_thread_sys_sigprocmask))
> -#else
>   call PIC_PLT(CNAME(sigprocmask))
> -#endif
>   addl $12,%esp
>   PIC_EPILOGUE
>   movl 4(%esp),%ecx
> @@ -91,11 +87,7 @@
>   leal 28(%edx), %eax
>   pushl %eax /* (sigset_t*)set  */
>   pushl $3 /* SIG_SETMASK     */
> -#ifdef _THREAD_SAFE
> - call PIC_PLT(CNAME(_thread_sys_sigprocmask))
> -#else
>   call PIC_PLT(CNAME(sigprocmask))
> -#endif
>   addl $12,%esp
>   PIC_EPILOGUE
>   movl 4(%esp),%edx
> Index: libc/i386/gen/sigsetjmp.S
> ===================================================================
> RCS file: /opt/FreeBSD/cvs/src/lib/libc/i386/gen/sigsetjmp.S,v
> retrieving revision 1.19.2.1
> diff -u -r1.19.2.1 sigsetjmp.S
> --- libc/i386/gen/sigsetjmp.S 2000/05/16 20:43:21 1.19.2.1
> +++ libc/i386/gen/sigsetjmp.S 2001/06/26 21:04:34
> @@ -70,11 +70,7 @@
>   pushl %eax /* (sigset_t*)oset */
>   pushl $0 /* (sigset_t*)set  */
>   pushl $1 /* SIG_BLOCK       */
> -#ifdef _THREAD_SAFE
> - call PIC_PLT(CNAME(_thread_sys_sigprocmask))
> -#else
>   call PIC_PLT(CNAME(sigprocmask))
> -#endif
>   addl $12,%esp
>   PIC_EPILOGUE
>   movl 4(%esp),%ecx
> @@ -102,11 +98,7 @@
>   leal 28(%edx), %eax
>   pushl %eax /* (sigset_t*)set  */
>   pushl $3 /* SIG_SETMASK     */
> -#ifdef _THREAD_SAFE
> - call PIC_PLT(CNAME(_thread_sys_sigprocmask))
> -#else
>   call PIC_PLT(CNAME(sigprocmask))
> -#endif
>   addl $12,%esp
>   PIC_EPILOGUE
>   movl 4(%esp),%edx
> Index: libc_r/uthread/uthread_sig.c
> ===================================================================
> RCS file: /opt/FreeBSD/cvs/src/lib/libc_r/uthread/uthread_sig.c,v
> retrieving revision 1.25.2.7
> diff -u -r1.25.2.7 uthread_sig.c
> --- libc_r/uthread/uthread_sig.c 2001/06/23 00:47:05 1.25.2.7
> +++ libc_r/uthread/uthread_sig.c 2001/06/26 20:56:52
> @@ -931,6 +931,12 @@
>   thread->curframe = NULL;
>   PTHREAD_ASSERT(psf != NULL, "Invalid signal frame in signal handler");
>
> + /*
> + * We came here from the kernel scheduler; clear the in scheduler
> + * flag.
> + */
> + _thread_kern_in_sched = 0;
> +
>   /* Check the threads previous state: */
>   if (psf->saved_state.psd_state != PS_RUNNING) {
>   /*
>
>


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to