From sbauer@rock.sdsmt.edu  Sun May  4 08:44:19 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 IAA00196
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 4 May 1997 08:44:18 -0700 (PDT)
Received: (from uurock@localhost)
	by krypton.hpc.sdsmt.edu (8.8.5/8.8.5) id JAA14592
	for FreeBSD-gnats-submit@freebsd.org; Sun, 4 May 1997 09:44:15 -0600
Received: (from root@localhost)
	by rock.sdsmt.edu (8.8.5/8.8.5) id JAA00639;
	Sun, 4 May 1997 09:34:50 -0600 (MDT)
Message-Id: <199705041534.JAA00639@rock.sdsmt.edu>
Date: Sun, 4 May 1997 09:34:50 -0600 (MDT)
From: Steve Bauer <sbauer@rock.sdsmt.edu>
Reply-To: sbauer@rock.sdsmt.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: memory allocation error in threaded file descriptor table for in uthead_init.c
X-Send-Pr-Version: 3.2

>Number:         3494
>Category:       kern
>Synopsis:       memory allocation error in libc_r -- uthread_init.c
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May  4 08:50:01 PDT 1997
>Closed-Date:    Tue May 13 16:58:52 PDT 1997
>Last-Modified:  Tue May 13 17:01:08 PDT 1997
>Originator:     Steve Bauer
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
South Dakota School of Mines and Technology
>Environment:

	The machine is currently running FreeBSD 2.2-Stable with ctm
patch 0263 applied.

>Description:

	There is an error in the way that the memory is allocated for the 
file descriptor table in the thread library libc_r.  The error is in the 
file uthread_init.c at line 172.  
	What is happening is that instead of allocating an array of pointers to
struct fd_table_entry it is allocating an array of stuct fd_table_entry.  This
does not cause a problem except that it wastes memory.

>How-To-Repeat:

	This doesn't cause a major problem except to waste memory.

>Fix:
	
	Below is a context diff that fixes the problem:

*** uthread_init.c.orig	Mon Apr 28 22:29:03 1997
--- uthread_init.c	Sun May  4 09:21:12 1997
***************
*** 169,175 ****
  			PANIC("Cannot get dtablesize");
  		}
  		/* Allocate memory for the file descriptor table: */
! 		if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry) * _thread_dtablesize)) == NULL) {
  			/*
  			 * Cannot allocate memory for the file descriptor
  			 * table, so abort this process. 
--- 169,175 ----
  			PANIC("Cannot get dtablesize");
  		}
  		/* Allocate memory for the file descriptor table: */
! 		if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
  			/*
  			 * Cannot allocate memory for the file descriptor
  			 * table, so abort this process. 
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: alex 
State-Changed-When: Tue May 13 16:58:52 PDT 1997 
State-Changed-Why:  
Patches applied to -current and 2.2.  Thanks! 
>Unformatted:
