This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcj and UDP datagrams under freebsd


>>> 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?

>> Exactly - good catch. We are forcing alignment for class objects but I 
>> forgot about static array objects. Please try this patch.

> I added your patch to my mainline and 3.1 trees; removed my posted
> hack from my mainline tree.  I will report ASAP.

Hi Bryce,

Test method: Fully bootstrapped and check mainline.  Added your patch.
quickstrapped gcc (i.e. rebuilt exactly two object files in gcc/java).
Freshly rebuilt libjava from scratch with new gcj.

I am fairly sure that the patch you sent to enforce 8 byte minimum
alignment in gcj doesn't work for me.  Crash at startup is seen in the
first call to _Jv_RegisterClassHookDefault called from
_Jv_RegisterClasses (called from ELF-style _init):

459       jint hash = HASH_UTF (klass->name);

Of course, I would print both klass and klass->name at this point to
help determine what is wrong.

I can't debug it any further with gdb since all I get is this message:

	can't find class named `java::lang::Class', as given by C++ RTTI

In case you know how to decode the layout of a Class (even looking at
the order of the fields in java/lang/Class.h, I can't), here is the
raw memory of the first entry in __JCR_LIST__ of the corrupt library:

0x28513780 <_ZN4java4util3jar10Attributes6class$E>:     0x0804a5f0      0x00000000      0x00000000      0x284a9b10
0x28513790 <_ZN4java4util3jar10Attributes6class$E+16>:  0x00000001      0x0804a578      0x00000002      0x284ef0c0
0x285137a0 <_ZN4java4util3jar10Attributes6class$E+32>:  0x285991e0      0x28513540      0x00140016      0x28513520
0x285137b0 <_ZN4java4util3jar10Attributes6class$E+48>:  0x00000010      0x00000001      0x28513708      0x00000000
0x285137c0 <_ZN4java4util3jar10Attributes6class$E+64>:  0x00000000      0x28513760      0x00000000      0x00000002
0x285137d0 <_ZN4java4util3jar10Attributes6class$E+80>:  0x00000000      0x00000000      0x00000000      0x00000000
0x285137e0 <_ZN4java4util3jar10Attributes6class$E+96>:  0x00000000      0x00000000      0x00000000      0x00000000
0x285137f0 <_ZN4java4util3jar10Attributes6class$E+112>: 0x00000000      0x00000000      0x00000000      0x00000000

Here is the first entry in __JCR_LIST__ of the well-build library:

0x28513b00 <_ZN4java4util3jar10Attributes6class$E>:     0x0804a5f0      0x00000000      0x284a9e90      0x00000001
0x28513b10 <_ZN4java4util3jar10Attributes6class$E+16>:  0x0804a578      0x00000002      0x284ef440      0x28599560
0x28513b20 <_ZN4java4util3jar10Attributes6class$E+32>:  0x285138c0      0x00140016      0x285138a0      0x00000008
0x28513b30 <_ZN4java4util3jar10Attributes6class$E+48>:  0x00000001      0x28513a88      0x00000000      0x00000000
0x28513b40 <_ZN4java4util3jar10Attributes6class$E+64>:  0x28513ae0      0x00000000      0x00000002      0x00000000
0x28513b50 <_ZN4java4util3jar10Attributes6class$E+80>:  0x00000000      0x00000000      0x00000000      0x00000000
0x28513b60 <_ZN4java4util3jar10Attributes6class$E+96>:  0x00000000      0x00000000      0x00000000      0x00000000
0x28513b70 <_ZN4java4util3jar10Attributes6class$E+112>: 0x00000000      0x00000000      0x00000000      0x00000000

I proposed this new test case:

	* libjava.lang/SyncGlobal.java, libjava.lang/SyncGlobal.out:
	New test case.

// Test suitability of alignment of statically-allocated Objects.
class SyncGlobal
{
  private static final byte[] global_1 = { 1 };
  private static final byte[] global_2 = { 2, 3 };
  private static final byte[] global_3 = { 4, 5, 6 };
  private static final byte[] global_4 = { 7, 8, 9, 10 };
  private static final byte[] global_5 = { 11, 12, 13, 14, 15 };
  private static final byte[] global_6 = { 16, 17, 18, 19, 20, 21 };
  private static final byte[] global_7 = { 22, 23, 24, 25, 26, 27, 28 };
  private static final byte[] global_8 = { 29, 30, 31, 32, 33, 34, 35, 36 };

  public static void main (String args[])
  {
    synchronized (global_1) { System.out.println ("PASS1"); }
    synchronized (global_2) { System.out.println ("PASS2"); }
    synchronized (global_3) { System.out.println ("PASS3"); }
    synchronized (global_4) { System.out.println ("PASS4"); }
    synchronized (global_5) { System.out.println ("PASS5"); }
    synchronized (global_6) { System.out.println ("PASS6"); }
    synchronized (global_7) { System.out.println ("PASS7"); }
    synchronized (global_8) { System.out.println ("PASS8"); }
  }
}

SyncGlobal.out:
PASS1
PASS2
PASS3
PASS4
PASS5
PASS6
PASS7
PASS8


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]