[kaffe] String problem / NullPointerException in KJC

Guilhem Lavaux guilhem.lavaux@free.fr
Wed Jul 2 13:02:01 2003


Hi,

I am using Mandrake 9.1 (with last updates) and I am trying from time to ti=
me=20
to compile kaffe and test it and I noticed in the latest Kaffe CVS that I w=
as=20
anymore able to compile kaffe with kjc: at the end of the compilation kaffe=
=20
returns 1 to gmake and the whole stops. With further investigation it appea=
rs=20
that kjc received a NullPointerException between the parsing of=20
java/security/SignatureSpi.java and  java/security/SignedObject.java. More=
=20
intriguating it seemed the NullPointerException was received from within th=
e=20
native function indexOf.

I then wondered if this may be caused by the original Boyer-Moore algorithm=
=20
implemented in Kaffe and so I tried to shutdown it: the problem disappeared=
=2E=20
Looking at the code I am a little surprised of one statement which can caus=
e=20
an "overread" of a string buffer:

        k=3D n - m+1;
       ^^^^^^^^^^^^^^
        for ( i=3Doffset; i <=3D k; ) {
          if ( memcmp( &a[i], p, m2) =3D=3D 0 )
                return i;
          i +=3D bs[ (unsigned char)a[i+m] ];
					^^^^^^^^^^^=20
       }

It seems that it is possible the algorithm wants to fetch a[n+1] and this m=
ay=20
cause the NullPointerException. Changing i<=3Dk in i<k solves the problem f=
or=20
KJC although I do know if it is the right to do because I am not really awa=
re=20
of the Boyer-Moore algorithm.

Any comments ? I included the log of KJC during the compilation of the core=
=20
classes.

Guilhem.

P.S.: I did not manage to raise the problem outside the particular case of =
KJC=20
compiling this files in that manner.

[ parsed java/security/SecureRandomSpi.java in 4 ms ]
[ parsed java/security/Security.java in 85 ms ]
[ parsed java/security/SecurityPermission.java in 5 ms ]
[ parsed java/security/SignatureException.java in 3 ms ]
<GC: heap 10244K, total before 8212K, after 6401K (110441/96148 objs)
 37.5% free, alloced 2305K (#25460), marked 3008K, swept 1811K (#14293)
 20 objs (0K) awaiting finalization>
[ parsed java/security/Signature.java in 320 ms ]
[ parsed java/security/SignatureSpi.java in 14 ms ]
java.lang.NullPointerException
        at java.lang.String.indexOf(String.java:native)
        at java.lang.String.indexOf(String.java:313)
        at at.dms.compiler.JavadocComment.isDeprecated(JavadocComment.java:=
48)
        at=20
at.dms.kjc.JMemberDeclaration.isDeprecated(JMemberDeclaration.java:61)
        at=20
at.dms.kjc.JTypeDeclaration.generateInterface(JTypeDeclaration.java:88)
        at=20
at.dms.kjc.CParseCompilationUnitContext.addTypeDeclaration(CParseCompilatio=
nUnitContext.java:74)
        at at.dms.kjc.KjcParser.jTypeDefinition(KjcParser.java:197)
        at at.dms.kjc.KjcParser.jCompilationUnit(KjcParser.java:52)
        at at.dms.kjc.Main.parseFile(Main.java:336)
        at at.dms.kjc.Main.run(Main.java:143)
        at at.dms.kjc.Main.compile(Main.java:69)
        at at.dms.kjc.Main.main(Main.java:60)
[ parsed java/security/SignedObject.java in 52 ms ]
[ parsed java/security/Signer.java in 8 ms ]
[ parsed java/security/spec/AlgorithmParameterSpec.java in 7 ms ]
[ parsed java/security/spec/DSAParameterSpec.java in 12 ms ]
[ parsed java/security/spec/DSAPrivateKeySpec.java in 13 ms ]