gcj seg fault in InetAddress.lookup

Jacob Gladish jake@gladish.info
Wed Jun 16 03:58:00 GMT 2004


Has anyone seen this segfault before? I’m running on freebsd 5.1, gcj
3.3.1. The strange part is that if I write a small unit test that just
calls the same exact code, it works.
InetAddress.getLocalHost().getHostName(). This leads me to suspect that
something is broken with my compilation. The dereference of "bytes"
seems to be causing it. Why didn't the call to elements fail? 


#0  java::net::InetAddress::lookup (host=0x0, iaddr=0xa1ffb40, all=0
'\0')
    at ../../../gcc-3.3.1/libjava/java/net/natInetAddress.cc:222
#1  0x2957f085 in java.net.InetAddress.getHostName() (this=0xa1ffb40)
    at ../../../gcc-3.3.1/libjava/java/net/InetAddress.java:258


natInetAddress.cc 

220       jbyteArray bytes = iaddr->addr;
221       char *chars = (char*) elements (bytes);
222       int len = bytes->length;
223       int type;
224       char *val;
225       if (len == 4)
226         {
227           val = chars;
228           type = iaddr->family = AF_INET;
229         }


(gdb) f 0
#0  java::net::InetAddress::lookup (host=0x0, iaddr=0xa1ffb40, all=0
'\0')
    at ../../../gcc-3.3.1/libjava/java/net/natInetAddress.cc:222
222     in ../../../gcc-3.3.1/libjava/java/net/natInetAddress.cc
(gdb) i locals
bytes = 0x0
chars = 0x2982e428 "X\004}"
len = 169868096
type = 44
val = 0x8eb1460 "\200\230Ä\bî\230Ä\b\001@ÿÿò\237M\b"
sync = {obj = 0xa6b3220}
hptr = (hostent *) 0x0
count = 696785039
result = (struct JArray<java::net::InetAddress*> *) 0x3f7ff1c8
iaddrs = (struct java::net::InetAddress **) 0x0



More information about the Java mailing list