gcj and UDP datagrams under freebsd

Loren James Rittle rittle@latour.rsch.comm.mot.com
Tue Apr 9 01:36:00 GMT 2002


In article <3CAE5D3C.1020501@waitaki.otago.ac.nz>,
Bryce McKinlay <bryce@waitaki.otago.ac.nz> writes:
> Yes, it would be good if you could figure out what "obj" is here (should 
> be easy to figure out from the stack trace), and why it isn't 8-byte 
> aligned.

Hi Bryce,
Agreed, it should be easy. ;-) FYI, I had to recompile selected files
without -O2 to get this information (but this could be a port rather
than a general issue). Here is the C++ code line in
libjava/java/net/natInetAddress.cc that uses the non-8-byte aligned
obj:
214 JvSynchronize sync (java::net::InetAddress::localhostAddress);
Here is the static (non-heap, non-stack) object declaration for that
object in libjava/java/net/InetAddress.java:
 private static final byte[] localhostAddress = { 127, 0, 0, 1 };
Does gcj force any alignment of static byte arrays such as this? Or,
rather, is it suppose to do so and failing to do so here?
Perhaps Mark didn't see it on Linux with his code since it uses a
different code path than FreeBSD 4 which doesn't define
HAVE_GETHOSTBYNAME_R. This is probably why it wasn't found when hash
synchronization was enabled everywhere.
>> Since I doubt I will be able to fix this before 3.1 release, I think
>> this should be disabled on the branch.

> Sounds ok to me.

A patch of this form appears to force the lock address to be gained
from GC malloc with correct alignment for the hash optimization but it
adds to the private part of the interface:
(I am not proposing this patch be installed as is. In terms of what
 should go into the libjava source tree itself: It seems like the
 gethostbynameImplLock should be conditionally allocated in
 natInetAddress.cc and not visible in InetAddress.java at all but I
 didn't know the preferred libjava code base way to do that.)
Index: libjava/java/net/InetAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
retrieving revision 1.7
diff -c -r1.7 InetAddress.java
*** libjava/java/net/InetAddress.java	12 Jan 2002 10:11:13 -0000	1.7
--- libjava/java/net/InetAddress.java	9 Apr 2002 07:28:25 -0000
***************
*** 246,251 ****
--- 246,253 ----
 
 private static final byte[] localhostAddress = { 127, 0, 0, 1 };
 
+ private static final Object gethostbynameImplLock = new Object();
+ 
 private static native String getLocalHostname ();
 
 private static InetAddress localhost = null;
Index: libjava/java/net/natInetAddress.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/natInetAddress.cc,v
retrieving revision 1.19
diff -c -r1.19 natInetAddress.cc
*** libjava/java/net/natInetAddress.cc	28 Feb 2002 01:03:37 -0000	1.19
--- libjava/java/net/natInetAddress.cc	9 Apr 2002 07:28:25 -0000
***************
*** 211,217 ****
 #else
 // FIXME: this is insufficient if some other piece of code calls
 // this gethostbyname.
! JvSynchronize sync (java::net::InetAddress::localhostAddress);
 hptr = gethostbyname (hostname);
 #endif /* HAVE_GETHOSTBYNAME_R */
 }
--- 211,217 ----
 #else
 // FIXME: this is insufficient if some other piece of code calls
 // this gethostbyname.
! JvSynchronize sync (java::net::InetAddress::gethostbynameImplLock);
 hptr = gethostbyname (hostname);
 #endif /* HAVE_GETHOSTBYNAME_R */
 }
***************
*** 265,271 ****
 #else /* HAVE_GETHOSTBYADDR_R */
 // FIXME: this is insufficient if some other piece of code calls
 // this gethostbyaddr.
! JvSynchronize sync (java::net::InetAddress::localhostAddress);
 hptr = gethostbyaddr (val, len, type);
 #endif /* HAVE_GETHOSTBYADDR_R */
 }
--- 265,271 ----
 #else /* HAVE_GETHOSTBYADDR_R */
 // FIXME: this is insufficient if some other piece of code calls
 // this gethostbyaddr.
! JvSynchronize sync (java::net::InetAddress::gethostbynameImplLock);
 hptr = gethostbyaddr (val, len, type);
 #endif /* HAVE_GETHOSTBYADDR_R */
 }


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /