From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 845 invoked by alias); 1 Mar 2002 08:06:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 819 invoked by uid 71); 1 Mar 2002 08:06:02 -0000 Date: Fri, 01 Mar 2002 00:06:00 -0000 Message-ID: <20020301080602.815.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Adam Dingle Subject: Re: java/5794: gcj fails to verify .class file generated by Sun JDK 1.4 compiler Reply-To: Adam Dingle X-SW-Source: 2002-03/txt/msg00000.txt.bz2 List-Id: The following reply was made to PR java/5794; it has been noted by GNATS. From: Adam Dingle To: tromey@redhat.com Cc: gcc-gnats@gcc.gnu.org Subject: Re: java/5794: gcj fails to verify .class file generated by Sun JDK 1.4 compiler Date: Fri, 01 Mar 2002 00:01:18 -0800 --Boundary_(ID_qN3wNA75EjmM1jjnp01ldQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Tom, > Could you upload the resulting .class file? > Just reply to this email and attach it, keeping gcc-gnats on the CC > line. No problem - I've attached the .class file to this reply. > Adam> When Sun's Java compiler in JDK 1.4 compiles a try...finally > Adam> block, it emits a (useless and unused) exception table entry > Adam> whose target is within the range of protected instructions. > Adam> There is nothing inherently unsafe with this, but we check for > Adam> this case and reject it in verify.c. > > It seems to me that this must be invalid. Well, I'm not sure. Section 4.9.5 of the Java Virtual Machine Specification does include the following text: "Java virtual machine code produced by Sun's compiler for the Java programming language always generates exception handlers such that ... The handler for an exception will never be inside the code that is being protected ... These restrictions are not enforced by the class file verifier since they do not pose a threat to the integrity of the Java virtual machine." (see http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html) > Adam> I tried that and then gcj complained about a stack overflow in > Adam> the same .class file. > > Yeah. Suppose the VM encounters an internal error and throws an > exception after it has set the PC to the start of the exception > handler but before the first instruction of the handler (probably a > pop or an astore) is executed. This leads inexorably to a stack > overflow. I imagine the gij verifier will die on this too. That is a scary thought, although it's hard for me to imagine any sort of error that might happen just at that moment. > I'd like to see the class file though. It's possible there are > obscure extenuating circumstances. Or perhaps they've tightened the > verification spec and I don't yet know about it. I'll be curious to see what you think. I do seem to get this kind of unusual exception table entry almost any time I compile a try...finally block with JDK 1.4. -adam --Boundary_(ID_qN3wNA75EjmM1jjnp01ldQ) Content-type: application/java; name=Foo.class Content-transfer-encoding: base64 Content-disposition: attachment; filename=Foo.class yv66vgAAAC4ADwoAAwAMBwANBwAOAQAGPGluaXQ+AQADKClWAQAEQ29kZQEAD0xpbmVOdW1iZXJU YWJsZQEABmludm9rZQEAAygpSQEAClNvdXJjZUZpbGUBAAhGb28uamF2YQwABAAFAQADRm9vAQAQ amF2YS9sYW5nL09iamVjdAAhAAIAAwAAAAAAAgABAAQABQABAAYAAAAdAAEAAQAAAAUqtwABsQAA AAEABwAAAAYAAQAAAAEAAQAIAAkAAQAGAAAAPAABAAQAAAAQBDyoAAsbrE2oAAUsv04FrAACAAAA BQAHAAAABwALAAcAAAABAAcAAAAKAAIAAAAGAAcACAABAAoAAAACAAs= --Boundary_(ID_qN3wNA75EjmM1jjnp01ldQ)--