Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Oct 2002 03:41:28 -0700
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        audit@FreeBSD.org
Cc:        current@FreeBSD.org
Subject:   I often have orphaned FDs in threaded programs...
Message-ID:  <20021017034126.A45732@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
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 <jmallett@FreeBSD.org>       | 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021017034126.A45732>