From sbauer@rock.sdsmt.edu  Sun May  4 08:44:20 1997
Received: from krypton.hpc.sdsmt.edu (uurock@krypton.hpc.sdsmt.edu [151.159.81.5])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id IAA00199
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 4 May 1997 08:44:19 -0700 (PDT)
Received: (from uurock@localhost)
	by krypton.hpc.sdsmt.edu (8.8.5/8.8.5) id JAA14600
	for FreeBSD-gnats-submit@freebsd.org; Sun, 4 May 1997 09:44:16 -0600
Received: (from root@localhost)
	by rock.sdsmt.edu (8.8.5/8.8.5) id JAA03968;
	Sun, 4 May 1997 09:47:08 -0600 (MDT)
Message-Id: <199705041547.JAA03968@rock.sdsmt.edu>
Date: Sun, 4 May 1997 09:47:08 -0600 (MDT)
From: Steve Bauer <sbauer@rock.sdsmt.edu>
Reply-To: sbauer@rock.sdsmt.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: error in _thread_fd_table setup in libc_r -- thread_init.c
X-Send-Pr-Version: 3.2

>Number:         3495
>Category:       kern
>Synopsis:       _thread_fd_table is not initialized with inherited fd's
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    jb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May  4 08:50:02 PDT 1997
>Closed-Date:    Tue Apr 28 22:42:11 PDT 1998
>Last-Modified:  Tue Apr 28 22:46:42 PDT 1998
>Originator:     Steve Bauer
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
South Dakota School of Mines and Technology
>Environment:

	The environment is the standard FreeBSD-2.2-Stable with ctm
patch 0263 applied to the system.
>Description:

	File desciptors that are inherited from the parent process (ie shell)
are not added to the _thread_fd_table.  Thus when they are accessed say using
read the error Bad File Descriptor is returned.  This effects programs that 
like to read from stdio using read.
>How-To-Repeat:

	Read data from stdin using read.
>Fix:
	
	Below is a patch that seems to fix the problem:

*** uthread_init.c.orig	Mon Apr 28 22:29:03 1997
--- uthread_init.c	Sun May  4 09:36:46 1997
***************
*** 183,188 ****
--- 183,189 ----
  			for (i = 0; i < _thread_dtablesize; i++) {
  				/* Initialise the file descriptor table: */
  				_thread_fd_table[i] = NULL;
+ 				_thread_fd_table_init(i);
  			}
  		}
  	}
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jb 
Responsible-Changed-By: hoek 
Responsible-Changed-When: Sun Mar 22 21:21:19 PST 1998 
Responsible-Changed-Why:  
Threads.  Includes one-line thimble. 
State-Changed-From-To: open->closed 
State-Changed-By: jb 
State-Changed-When: Tue Apr 28 22:42:11 PDT 1998 
State-Changed-Why:  
The entries in the fd table are initialised as they are accessed 
for the first time. The problem being reported was fixed in a different 
way. 8-) 
>Unformatted:
