Bug 22277 - IllegalArgumentException in setOutputLineIncrement()
Summary: IllegalArgumentException in setOutputLineIncrement()
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: Nightly Build
Hardware: All All
: P3 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 22508 22678 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-08-10 08:31 UTC by Eric Carmichael
Modified: 2004-11-16 19:05 UTC (History)
2 users (show)



Attachments
Proposed patch (1.24 KB, patch)
2003-08-10 08:33 UTC, Eric Carmichael
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carmichael 2003-08-10 08:31:50 UTC
Jasper sometimes generates SMAP LineInfo entries with an outputStartLine of 
0.  These LineInfo entries are incorrect, and also can cause a fatal error in 
SmapStratum.java's optimizeLineSection(), making it impossible for Jasper to 
compile the JSP.

Note that the incorrect entries predate optimizeLineSection (they were present 
in Tomcat 5.0.4, and possibly earlier), but optimizeLineSection does blow the 
problem out of proportion, turning a flawed SMAP into a failed compilation.  I 
will attach a patch that fixes the blowing-out-of-proportion problem, at 
least, in order to make Tomcat more usable until I (or anyone else who wants 
to try their hand) can fix the underlying outputStartLine=0 problem.  Another 
workaround is to set suppressSmap=true.

The problem can be reproduced by compiling xml/xml.jsp from the jsp-examples 
webapp that ships with Tomcat 5.  The SMAP generated for that JSP is as 
follows:

C:\Program Files\jakarta-tomcat-5.0.4
\work\Catalina\localhost\test\org\apache\jsp\xml\xml_jsp.java
JSP
*S JSP
*F
+ 0 xml.jsp
/xml/xml.jsp
*L
8:0
15:0,0
16:0,0
17:0,0
17:47
20:0,0
21:51
22:0,0
24:0,0
24:54
25:56
39:57
42:0,0
43:59
44:60
48:0,0
49:64
49:65
49:66
49:67
49:68
49:69
49:70
*E
Comment 1 Eric Carmichael 2003-08-10 08:33:06 UTC
Created attachment 7716 [details]
Proposed patch
Comment 2 Remy Maucherat 2003-08-10 08:41:29 UTC
I have applied your workaround.
Comment 3 Yann Cébron 2003-08-12 06:05:46 UTC
I'm not sure, but I think I have a related (same?) problem here:

My JSPs compiled with TC5.0.5/6, but fail all with TC5.0.7

Ofcourse numbers vary, but all are negative (?!). I can provide sample JSPs on 
request, but I don't have anything special going on there (Struts/JSTL-tags).

Sample Stacktrace (always the same):

2003-08-12 07:57:15 StandardWrapperValve[jsp]: Servlet.service() for servlet 
jsp threw exception
java.lang.IllegalArgumentException: -41
	at 
org.apache.jasper.compiler.SmapStratum$LineInfo.setOutputLineIncrement
(SmapStratum.java:124)
	at org.apache.jasper.compiler.SmapStratum.optimizeLineSection
(SmapStratum.java:221)
	at org.apache.jasper.compiler.SmapUtil.evaluateNodes(SmapUtil.java:490)
	at org.apache.jasper.compiler.SmapUtil.generateSmap(SmapUtil.java:123)
	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:301)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
	at org.apache.jasper.JspCompilationContext.compile
(JspCompilationContext.java:555)
	at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:300)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:293)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:286)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:254)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardContextValve.invokeInternal
(StandardContextValve.java:256)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:210)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:501)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:149)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:190)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:175)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:149)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:156)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:564)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:974)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service
(CoyoteAdapter.java:207)
	at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:647)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnectio
n(Http11Protocol.java:489)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:575)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:649)
	at java.lang.Thread.run(Thread.java:534)
Comment 4 Eric Carmichael 2003-08-12 07:08:04 UTC
That's the same problem.  No need to provide sample JSPs (although I 
appreciate the offer); a patch fixing the crashing problem is already attached 
to this ticket and incorporated into CVS, and I'm looking into the best way to 
eliminate the root cause.

To make it easier for other people having this problem to find this ticket, 
I'm changing the summary from "SMAP LineInfo entries with an outputStartLine 
of 0" (the root cause) to "IllegalArgumentException in setOutputLineIncrement
()" (the error people actually see).
Comment 5 Remy Maucherat 2003-08-12 07:43:32 UTC
Wrokaround: set "supressSmap" to "true" in "conf/web.xml".
Comment 6 Eric Carmichael 2003-08-13 07:15:24 UTC
I believe Remy's commit from earlier today ("Don't merge SMAP entries in the 
outptStartLines aren't consecutive") fixes the IllegalArgumentException 
problem (thanks, Remy!).  If that's right (I've tested it, but then I tested 
my original patch as well, so I'm not taking that as a guarantee), it means my 
workaround patch can be removed without IllegalArgumentException recurring.  
On the other hand the workaround patch also keeps the outputStartLine=0 
LineInfos out of the SMAP, so taking it out before we've fixed the root cause 
of outputStartLine=0 could be considered a regression, on the grounds that an 
incorrect SMAP is worse than an incomplete one.

Also, if Jasper were to start SMAPping page directives, then

	TemplateText<page import="org.foo.*">

would generate an IllegalArgumentException if it weren't for Remy's fix.  This 
means that IllegalArgumentException is a bug in its own right, and not just a 
side effect of the outputStartLine=0 problem.  So to keep things clear, I 
think we should use this ticket to track IllegalArgumentException only, and 
open new tickets as needed to track outputStartLine=0.

I'll close this ticket in a few days if there are no objections to this 
approach, and no reason to doubt Remy's commit.  If someone else wants to 
close it sooner, that's fine with me.
Comment 7 Remy Maucherat 2003-08-13 07:22:27 UTC
There's a side problem that causes the mappings to be incorrect for tags
invocations which are done in separate methods, rather than inside _jspService.
That's what really did cause the bug. I agree that this is fixed, and the other
issues are other bugs.
Comment 8 Eric Carmichael 2003-08-18 14:13:32 UTC
*** Bug 22508 has been marked as a duplicate of this bug. ***
Comment 9 Eric Carmichael 2003-08-24 02:48:11 UTC
*** Bug 22678 has been marked as a duplicate of this bug. ***