[kaffe] String problem / NullPointerException in KJC

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


Hi,

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

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

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

It seems that it is possible the algorithm wants to fetch a[n+1] and this may 
cause the NullPointerException. Changing i<=k in i<k solves the problem for 
KJC although I do know if it is the right to do because I am not really aware 
of the Boyer-Moore algorithm.

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

Guilhem.

P.S.: I did not manage to raise the problem outside the particular case of KJC 
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 
at.dms.kjc.JMemberDeclaration.isDeprecated(JMemberDeclaration.java:61)
        at 
at.dms.kjc.JTypeDeclaration.generateInterface(JTypeDeclaration.java:88)
        at 
at.dms.kjc.CParseCompilationUnitContext.addTypeDeclaration(CParseCompilationUnitContext.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 ]





More information about the kaffe mailing list