From owner-freebsd-hackers Fri Sep 20 18:37:27 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id SAA16557 for hackers-outgoing; Fri, 20 Sep 1996 18:37:27 -0700 (PDT) Received: from melb.werple.net.au (melb.werple.net.au [203.9.190.18]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id SAA16528 for ; Fri, 20 Sep 1996 18:37:24 -0700 (PDT) Received: (from uucp@localhost) by melb.werple.net.au (8.7.6/8.7.3/2) with UUCP id KAA28219; Sat, 21 Sep 1996 10:58:29 +1000 (EST) Received: (from jb@localhost) by freebsd3.cimlogic.com.au (8.7.5/8.7.3) id JAA14006; Sat, 21 Sep 1996 09:12:24 +1000 (EST) From: John Birrell Message-Id: <199609202312.JAA14006@freebsd3.cimlogic.com.au> Subject: Re: libc_r bug To: hsu@freefall.freebsd.org (Jeffrey Hsu) Date: Sat, 21 Sep 1996 09:12:23 +1000 (EST) Cc: hackers@FreeBSD.org, jb@cimlogic.com.au In-Reply-To: <199609202133.OAA05442@freefall.freebsd.org> from Jeffrey Hsu at "Sep 20, 96 02:33:28 pm" X-Mailer: ELM [version 2.4ME+ PL22 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > > What happens, and what do you expect to happen? > > The first write gets lost. This is because the uthreads internal > fd table is not set up for fds which are inherited from the parent > process. I got around it with the following hack. This workaround > is bad because it assumes that fd 0, 1, and 2 are valid upon > start-up, which is generally but universally true. Alternatively, The workaround is "the fix" (provided that the calls to _thread_fd_table_init are _after_ the initialisation loop). _thread_fd_table_init() just sets up the table for a fd. fds 0, 1 and 2 don't have to be valid. > one could place a call to _thread_fd_table_init() in uthreads_write.c. > Neither solution is very stisfactory. > > *** uthread_init.c 1996/08/20 08:21:23 1.3 > --- uthread_init.c 1996/09/20 18:18:53 > *************** > *** 176,186 **** > */ > PANIC("Cannot allocate memory for file descriptor table"); > } else { > /* > * Enter a loop to initialise the file descriptor > * table: > */ > ! for (i = 0; i < _thread_dtablesize; i++) { > /* Initialise the file descriptor table: */ > _thread_fd_table[i] = NULL; > } > --- 176,189 ---- > */ > PANIC("Cannot allocate memory for file descriptor table"); > } else { > + _thread_fd_table_init(0); > + _thread_fd_table_init(1); > + _thread_fd_table_init(2); > /* > * Enter a loop to initialise the file descriptor > * table: > */ > ! for (i = 2; i < _thread_dtablesize; i++) { > /* Initialise the file descriptor table: */ > _thread_fd_table[i] = NULL; > Leave the loop starting at i = 0 so that _thread_fd_table_init(0) etc can check if memory has been allocated, then put the _thread_fd_table_init calls after the loop. Regards, -- John Birrell CIMlogic Pty Ltd jb@cimlogic.com.au 119 Cecil Street Ph +61 3 9690 6900 South Melbourne Vic 3205 Fax +61 3 9690 6650 Australia Mob +61 18 353 137