You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Danno Ferrin <DF...@novell.com> on 1999/11/12 01:08:01 UTC

Bug in Taglibs

An interesting compiler/verfier bug of 1.1 and 1.2 causes a legit taglib definition to fail on a verification error.  Basically jasper creates a code block 
try {
    do {
        // end
        // begin
    } while (false);
} catch (Throwable t) {
    System.err.println("Caught: ");
    t.printStackTrace();
} finally {
}
which makes the verifier freak out (but not under JDK 1.3 say the sun bug people... but I am not sure if it is compiling under one and running under the other or all 1.3) .  Basically the empty try block maps an exception to a single jump instruction, which in essense would make the catch block un-readable.   A current work around is to use and make no empty or functionally empty tags.

Possible fixes include putting a bogus instruction in there to add at lease one more jvm instruction.  Another is to get rid of the try block since the exact same code block seems to be in great abundance... but that allows the page authot to catch exceptions coming out from opening and closing tags rather than silently failing.  The best fix is to not write the block if the tag has no content, but that would require some co-operation between TagBeginGenerator and TagEndGenerator.  

Perhaps a special TagEmptyGenerator?  Or an extra constructor parameter to TagBeginGenerator and TagEndGenerator?  The parsing code would also need to look ahead to see if the current tag is an empty tag or if the next immedate content is the corresponding close tag.

Attached is code that can make it freak out.
--Danno


Re: Bug in Taglibs

Posted by "Anil K. Vijendran" <An...@eng.sun.com>.
Hi Danno,

Yep, I know about this bug. It was fixed atleast a few weeks back. If you are using the latest sources, you shouldn't be seeing this.


Danno Ferrin wrote:

> An interesting compiler/verfier bug of 1.1 and 1.2 causes a legit taglib definition to fail on a verification error.  Basically jasper creates a code block
> try {
>     do {
>         // end
>         // begin
>     } while (false);
> } catch (Throwable t) {
>     System.err.println("Caught: ");
>     t.printStackTrace();
> } finally {
> }
> which makes the verifier freak out (but not under JDK 1.3 say the sun bug people... but I am not sure if it is compiling under one and running under the other or all 1.3) .  Basically the empty try block maps an exception to a single jump instruction, which in essense would make the catch block un-readable.   A current work around is to use and make no empty or functionally empty tags.
>
> Possible fixes include putting a bogus instruction in there to add at lease one more jvm instruction.  Another is to get rid of the try block since the exact same code block seems to be in great abundance... but that allows the page authot to catch exceptions coming out from opening and closing tags rather than silently failing.  The best fix is to not write the block if the tag has no content, but that would require some co-operation between TagBeginGenerator and TagEndGenerator.
>
> Perhaps a special TagEmptyGenerator?  Or an extra constructor parameter to TagBeginGenerator and TagEndGenerator?  The parsing code would also need to look ahead to see if the current tag is an empty tag or if the next immedate content is the corresponding close tag.
>
> Attached is code that can make it freak out.
> --Danno
>
>   ------------------------------------------------------------------------
>                Name: test.jsp
>    test.jsp    Type: Plain Text (text/plain)
>            Encoding: base64
>
>                        Name: verifyerror.java
>    verifyerror.java    Type: Plain Text (text/plain)
>                    Encoding: base64
>
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

--
Peace, Anil +<:-)