From nobody  Mon Dec 21 19:22:45 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id TAA11475;
          Mon, 21 Dec 1998 19:22:45 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199812220322.TAA11475@hub.freebsd.org>
Date: Mon, 21 Dec 1998 19:22:45 -0800 (PST)
From: eischen@vigrid.com
To: freebsd-gnats-submit@freebsd.org
Subject: [Patch] pthreads GC breaks signal handling
X-Send-Pr-Version: www-1.0

>Number:         9162
>Category:       bin
>Synopsis:       [Patch] pthreads GC breaks signal handling
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 21 19:30:01 PST 1998
>Closed-Date:    Wed Aug 4 04:57:33 PDT 1999
>Last-Modified:  Wed Aug  4 04:58:35 PDT 1999
>Originator:     Daniel Eischen
>Release:        2.2.8-stable and 3.0-current
>Organization:
>Environment:
FreeBSD klr.clc.gdeb.com 2.2.7-STABLE FreeBSD 2.2.7-STABLE #0: Thu Oct 22 18:12:35 EDT 1998     deischen@klr.clc.gdeb.com:/opt/b/src/src/sys/compile/klr  i386
>Description:
If a threaded program installs a handler for a signal, and this program
receives that signal, then the signal handler is invoked for the garbage
collector thread.  The GC thread should be transparent to the application
and no signal handlers should be called as a result of it being present.
>How-To-Repeat:
Build and run libc_r/uthread/test/sigwait/sigwait.c (these tests
are there for a reason, no? ;-))
>Fix:
One fix is to block all signals in the garbage collector thread.
Here is a patch:

*** uthread_gc.c.orig	Mon Dec 21 22:08:54 1998
--- uthread_gc.c	Mon Dec 21 22:11:34 1998
***************
*** 47,52 ****
--- 47,53 ----
  	int		f_debug;
  	int		f_done = 0;
  	int		ret;
+ 	sigset_t	mask;
  	pthread_t	pthread;
  	pthread_t	pthread_cln;
  	pthread_t	pthread_nxt;
***************
*** 59,64 ****
--- 60,69 ----
  
  	/* Set the name of this thread. */
  	pthread_set_name_np(_thread_run,"GC");
+ 
+ 	/* Block all signals. */
+ 	sigfillset(&mask);
+ 	sigprocmask(SIG_BLOCK, &mask, NULL);
  
  	while (!f_done) {
  		/* Check if debugging this application. */

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: deischen 
State-Changed-When: Wed Aug 4 04:57:33 PDT 1999 
State-Changed-Why:  
I originated the PR and am satisfied with the fix. 
>Unformatted:
