This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

java/5042: java: wrong addressing of inner class attributes



>Number:         5042
>Category:       java
>Synopsis:       java: wrong addressing of inner class attributes
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 07 06:36:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.1 20011206 (experimental)
>Organization:
>Environment:
System: Linux isabella 2.4.10-4GB #1 Tue Sep 25 12:33:54 GMT 2001 i586 unknown
Architecture: i586

	
host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: /home/roland/gcc/configure  : (reconfigured) /home/roland/gcc/configure --enable-threads=posix --enable-shared --enable-languages=c++,java : (reconfigured) /home/roland/gcc/configure  : (reconfigured) /home/roland/gcc/configure --disable-libf2c : (reconfigured) /home/roland/gcc/configure --enable-threads=posix --enable-languages=c,c++,java : (reconfigured)  : (reconfigured) 
>Description:

A Xerces1 built with gcj throws an exception, where a jvm succeeds. I
debugged the problematic area and found failing references to
attributes of an inner class, that was defined in another file.

The problematic area is /org/apache/xerces/readers/AbstractCharReader.java:

    public boolean scanExpectedName(char fastcheck, StringPool.CharArrayRange expectedName) throws Exception {
        char[] expected = expectedName.chars;
        int offset = expectedName.offset;
        int len = expectedName.length;
        int ch = fMostRecentChar;
        for (int i = 0; i < len; i++) {
            if (ch != expected[offset++]) {

Note the type of the expectedName parameter:
StringPool.CharArrayRange. It is defined in
org/apache/xerces/utils/StringPool.java:

public final class StringPool {
...
    public class CharArrayRange {
        public char[] chars;
        public int offset;
        public int length;
    }

The assembler code was generated via libtool with
gcj --encoding=UTF-8 -fassume-compiled\
 -fCLASSPATH=../../../../../src -ffloat-store\
 -gstabs+ --save-temps -MD -MT AbstractCharReader.lo -MF\
 AbstractCharReader.d -c AbstractCharReader.java\
 -o AbstractCharReader.o

Here the relevant parts from AbstractCharReader.s .

[........]
	.stabs	"_ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE:F(0,10)",36,0,50463458,_ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE
	.stabs	"this:p(0,35)",160,0,738,8
	.stabs	"fastcheck:p(0,1)",160,0,738,12
	.stabs	"expectedName:p(0,55)=*(0,56)=xsorg.apache.xerces.utils.StringPool$CharArrayRange:",160,0,738,16
.globl _ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE
	.type	_ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE,@function
_ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE:
[...]
	.stabn 68,0,739,.LM407-_ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE
.LM407:
	movl	16(%ebp), %eax
	movl	4(%eax), %eax
	movl	%eax, -8(%ebp)
.LBB139:
	.stabn 68,0,740,.LM408-_ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE
.LM408:
	movl	16(%ebp), %eax
	movl	8(%eax), %eax
	movl	%eax, -12(%ebp)
.LBB140:
	.stabn 68,0,741,.LM409-_ZN3org6apache6xerces7readers18AbstractCharReader16scanExpectedNameEwPNS1_5utils30StringPool__U24_CharArrayRangeE
.LM409:
	movl	16(%ebp), %eax
	movl	12(%eax), %eax
	movl	%eax, -16(%ebp)
[........]
	.stabs	"fastcheck:(0,2)",128,0,738,-2
	.stabs	"expected:(0,53)",128,0,739,-8
	.stabn	192,0,0,.LBB138-.LFB22
	.stabs	"offset:(0,1)",128,0,740,-12
	.stabn	192,0,0,.LBB139-.LFB22
	.stabs	"len:(0,1)",128,0,741,-16
	.stabn	192,0,0,.LBB140-.LFB22
	.stabs	"ch:(0,1)",128,0,742,-20
	.stabn	192,0,0,.LBB141-.LFB22
	.stabs	"i:(0,1)",128,0,743,-24

This assembler code is according to the type with one <this> pointer as
first element, chars pointer the second element:

(gdb) ptype expectedName
type = class org.apache.xerces.utils.StringPool$CharArrayRange 
     extends java.lang.Object {
    private org.apache.xerces.utils.StringPool this$0;
    public class char[] chars;
    public int offset;
    public int length;

    StringPool__U24_CharArrayRange(org.apache.xerces.utils.StringPool);
}

But apparently there is a second invisible element in expectedName, and chars is
the third element, offset the fourth, etc:

(gdb) i lo
expected = char[]@8634f80
offset = 140963840
len = 357
(gdb) p/x offset
$8 = 0x866f000
(gdb) p expectedName
$9 = org.apache.xerces.utils.StringPool$CharArrayRange@8693498
(gdb) p expectedName.chars
$10 = char[]@866f000
(gdb) p expectedName.offset
$11 = 357
(gdb) p expectedName.length
$12 = 13


>How-To-Repeat:
	It is impossible for me to isolate a test case from xerces. 
	I'd have to build an independent test case. Please mail me, if
	you need it.

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


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