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 <[EMAIL PROTECTED]>       | FreeBSD: The Power To Serve
Will break world for fulltime employment. | finger [EMAIL PROTECTED]
http://people.FreeBSD.org/~jmallett/      | Support my FreeBSD hacking!

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to