From owner-freebsd-bugs Fri Apr 17 01:10:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA02974 for freebsd-bugs-outgoing; Fri, 17 Apr 1998 01:10:34 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA02927; Fri, 17 Apr 1998 01:10:20 -0700 (PDT) (envelope-from gnats) Received: from sys1.microline.org (jkf@microline.org [207.173.132.199]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA02344 for ; Fri, 17 Apr 1998 08:05:45 GMT (envelope-from jkf@sys1.microline.org) Received: (from jkf@localhost) by sys1.microline.org (8.8.8/8.8.7) id BAA22860; Fri, 17 Apr 1998 01:05:25 -0700 (PDT) (envelope-from jkf) Message-Id: <199804170805.BAA22860@sys1.microline.org> Date: Fri, 17 Apr 1998 01:05:25 -0700 (PDT) From: "Jason K. Fritcher" Reply-To: fritcher@calweb.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: misc/6329: _thread_flockfile hangs with NULL file pointer. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 6329 >Category: misc >Synopsis: _thread_flockfile hangs with NULL file pointer. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Apr 17 01:10:14 PDT 1998 >Last-Modified: >Originator: Jason K. Fritcher >Organization: N/A >Release: FreeBSD 2.2.6-STABLE i386 >Environment: FreeBSD sys1.microline.org 2.2.6-STABLE FreeBSD 2.2.6-STABLE #0: Sun Apr 5 14:20:20 PDT 1998 root@sys1.microline.org:/usr/src/sys/compile/microline i386 >Description: Calling any function that calls _thread_flockfile with a file pointer that happens to be NULL, the function will hang, and consume call idle cpu time. >How-To-Repeat: Save this to a file, ie blah.c. #include #include main() { FILE* fBlah = NULL; fprintf(fBlah, "Blah\n"); } Then do this: gcc -lc_r -o blah blah.c ./blah hangs. Have to 'kill -9' to stop. But this: gcc -o blah blah.c ./blah core dumps as expected. >Fix: Apply this patch to /usr/src/lib/libc_r/uthread/uthread_file.c --- uthread_file.c.old Sun Jan 21 16:23:18 1996 +++ uthread_file.c Thu Apr 16 23:51:22 1998 @@ -42,10 +42,12 @@ int fd, flags; int status; - /* Block signals: */ - _thread_kern_sig_block(&status); if ((fd = fileno(fp)) >= 0) { + /* Block signals: */ + _thread_kern_sig_block(&status); + + if (fp->_flags & __SRW) { flags = FD_READ | FD_WRITE; } else { @@ -58,9 +60,10 @@ /* This might fail but POSIX doesn't give a damn. */ _thread_fd_lock(fd, flags, NULL, fname, lineno); + + /* Unblock signals: */ + _thread_kern_sig_unblock(status); } - /* Unblock signals: */ - _thread_kern_sig_unblock(status); return; } >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message