From owner-freebsd-current Thu Oct 17 3:41:30 2002 Delivered-To: freebsd-current@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 931) id AF8DE37B401; Thu, 17 Oct 2002 03:41:28 -0700 (PDT) Date: Thu, 17 Oct 2002 03:41:28 -0700 From: Juli Mallett To: audit@FreeBSD.org Cc: current@FreeBSD.org Subject: I often have orphaned FDs in threaded programs... Message-ID: <20021017034126.A45732@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Organisation: The FreeBSD Project X-Alternate-Addresses: , , , , X-Towel: Yes X-LiveJournal: flata, jmallett X-Negacore: Yes Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I have a program which shares a lot of (orphaned) FDs between threads, and requesting a dump (SIGINFO) results in a core, because the FD owner si NULL. Here's a diff from my local tree, for review: %%% Index: uthread_info.c =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_info.c,v retrieving revision 1.21 diff -d -u -r1.21 uthread_info.c --- uthread_info.c 13 Oct 2002 11:23:31 -0000 1.21 +++ uthread_info.c 17 Oct 2002 10:38:49 -0000 @@ -252,10 +252,16 @@ pthread->data.fd.fname, pthread->data.fd.branch); __sys_write(fd, s, strlen(s)); - snprintf(s, sizeof(s), "owner %pr/%pw\n", - _thread_fd_table[pthread->data.fd.fd]->r_owner, - _thread_fd_table[pthread->data.fd.fd]->w_owner); - __sys_write(fd, s, strlen(s)); + /* + * XXX _thread_fd_table[pthread->data.fd.fd] often comes + * up as NULL for me, bandaid it. Is this right? + */ + if (_thread_fd_table[pthread->data.fd.fd] != NULL) { + snprintf(s, sizeof(s), "owner %pr/%pw\n", + _thread_fd_table[pthread->data.fd.fd]->r_owner, + _thread_fd_table[pthread->data.fd.fd]->w_owner); + __sys_write(fd, s, strlen(s)); + } break; case PS_SIGWAIT: snprintf(s, sizeof(s), "sigmask (hi)"); %%% I think it's right to just print no owner, or possibly a no owner message, in these cases. Comments? -- Juli Mallett | FreeBSD: The Power To Serve Will break world for fulltime employment. | finger jmallett@FreeBSD.org http://people.FreeBSD.org/~jmallett/ | Support my FreeBSD hacking! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message