[OpenAFS-devel] Segfaulting rxdebug on linux x86_64, offer fix, questions

Matt Benjamin matt@linuxbox.com
Sun, 07 Nov 2004 19:16:53 -0500


This is a multi-part message in MIME format.
--------------000406040600030508050506
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I've been working with OpenAFS CVS (and 1.3.73) on a dual x86_64 (SuSE 
9.1, Glibc 2.2.5), and very shortly ran up against a segfault in rxdebug.

This looks pretty obvious--if afs_inet_ntoa_r is used, there is no problem.

The patch I've included seems naive, in that usage of inet_ntoa, 
afs_inet_ntoa, and afs_inet_ntoa_r seem to be used interchangeably. 

Variously,

1. shouldn't the afs_inet_ntoa/r functions be used in all cases?
2. should the /r function be provided in an ifdef, or is this taken care 
of by the build system in a way that I missed (or, might we always use /r?)
3. if 2, should which of the functions should I have used?
(4. should we be using inet_ntop at some point?)

(I'm  hoping to be instructed in doing it right.)

Nb, if I used the afs_inet_nota_r rvalue directly, I still observed a 
segfault.  Using argument 2 (as in vos.c) seems to work.

Matt

-- 

Matt Benjamin

The Linux Box
206 South Fifth Ave. Suite 150
Ann Arbor, MI  48104

tel. 734-761-4689
fax. 734-769-8938
cel. 734-216-5309


--------------000406040600030508050506
Content-Type: text/x-patch;
 name="rxdebug.ntoa_r.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="rxdebug.ntoa_r.patch"

--- rxdebug.c	2004-11-07 18:51:47.889728066 -0500
+++ rxdebug.c.ntoa_r	2004-11-07 18:48:29.613894102 -0500
@@ -114,6 +114,7 @@
     int withPeers;
     struct rx_debugStats tstats;
     char *portName, *hostName;
+    char hoststr[20];
     struct rx_debugConn tconn;
     short noConns;
     short showPeers;
@@ -216,7 +217,8 @@
     dallyCounter = 0;
 
     hostAddr.s_addr = host;
-    printf("Trying %s (port %d):\n", inet_ntoa(hostAddr), ntohs(port));
+    afs_inet_ntoa_r(hostAddr, hoststr);
+    printf("Trying %s (port %d):\n", hoststr, ntohs(port));
     s = socket(AF_INET, SOCK_DGRAM, 0);
     taddr.sin_family = AF_INET;
     taddr.sin_port = 0;
@@ -322,8 +324,9 @@
 	}
 	if (onlyHost != -1) {
 	    hostAddr.s_addr = onlyHost;
+	    afs_inet_ntoa_r(hostAddr, hoststr);
 	    printf("Showing only connections from host %s\n",
-		   inet_ntoa(hostAddr));
+		   hoststr);
 	}
 	if (onlyPort != -1)
 	    printf("Showing only connections on port %u\n", ntohs(onlyPort));
@@ -382,7 +385,8 @@
 
 	    /* now display the connection */
 	    hostAddr.s_addr = tconn.host;
-	    printf("Connection from host %s, port %hu, ", inet_ntoa(hostAddr),
+	    afs_inet_ntoa_r(hostAddr, hoststr);
+	    printf("Connection from host %s, port %hu, ", hoststr,
 		   ntohs(tconn.port));
 	    if (tconn.epoch)
 		printf("Cuid %x/%x", tconn.epoch, tconn.cid);
@@ -544,7 +548,8 @@
 
 	    /* now display the peer */
 	    hostAddr.s_addr = tpeer.host;
-	    printf("Peer at host %s, port %hu\n", inet_ntoa(hostAddr),
+	    afs_inet_ntoa_r(hostAddr, hoststr);
+	    printf("Peer at host %s, port %hu\n", hoststr, 
 		   ntohs(tpeer.port));
 	    printf("\tifMTU %hu\tnatMTU %hu\tmaxMTU %hu\n", tpeer.ifMTU,
 		   tpeer.natMTU, tpeer.maxMTU);

--------------000406040600030508050506--