Date: Fri, 17 Apr 1998 01:05:25 -0700 (PDT) From: "Jason K. Fritcher" <jkf@microline.org> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: misc/6329: _thread_flockfile hangs with NULL file pointer. Message-ID: <199804170805.BAA22860@sys1.microline.org>
next in thread | raw e-mail | index | archive | help
>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 <pthread.h> #include <stdio.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804170805.BAA22860>