Compiler NPE crash with CFFinally block (when CFCatch contains CFReturn)

Description

The following code causes the Lucee compiler to crash with an NPE:

<cffunction name="doSomething" returntype="boolean">
<cftry>
<cfoutput>something here... in a CFOutput<br /></cfoutput>

<cfcatch>
<cfoutput>exception caught<br /></cfoutput>
<cfreturn false> <!--- this causes NPE in the compiler --->
</cfcatch>

<cffinally>
<cfscript>
WriteOutput("in 'finally' block");
</cfscript>
</cffinally>
</cftry>
<cfreturn true>
</cffunction>

<cfoutput>got here<br /></cfoutput>

=================

work-around is simple - set a variable in the CFCatch block instead of returning directly from there - but this shouldn't crash anyway (and doesn't with ACF)

Environment

Lucee 5.3.2.77, Java 11.0.3 (AdoptOpenJDK) 64bit [as installed w/Lucee], CentOS 7 with all available patches

Activity

Zac Spitzer 
23 July 2022 at 11:03

Pothys - MitrahSoft 
11 August 2021 at 15:19

NPE throws while using block ( like cfsavecontent, cftransaction, cfdocument) in cffinally block, which has another try-catch.

Zac Spitzer 
11 August 2021 at 14:49

Lucee 5.3.8.189-SNAPSHOT Error (java.lang.NullPointerException)
Message java.lang.NullPointerException
Java Stacktrace lucee.runtime.exp.NativeException: java.lang.NullPointerException
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at org.objectweb.asm.commons.GeneratorAdapter.endMethod(Unknown Source)
at lucee.transformer.bytecode.Page.execute(Page.java:496)
at lucee.runtime.compiler.CFMLCompilerImpl._compile(CFMLCompilerImpl.java:109)
at lucee.runtime.compiler.CFMLCompilerImpl.compile(CFMLCompilerImpl.java:76)
at lucee.runtime.PageSourceImpl._compile(PageSourceImpl.java:436)
at lucee.runtime.PageSourceImpl.compile(PageSourceImpl.java:403)
at lucee.runtime.PageSourceImpl.loadPhysical(PageSourceImpl.java:344)
at lucee.runtime.PageSourceImpl.loadPageThrowTemplateException(PageSourceImpl.java:237)

another similar NPE occurs with cfloop in cffinally

lucee.runtime.exp.NativeException: java.lang.NullPointerException
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at org.objectweb.asm.commons.GeneratorAdapter.endMethod(Unknown Source)
at lucee.transformer.bytecode.Page.writeOutCall(Page.java:1440)
at lucee.transformer.bytecode.Page.execute(Page.java:463)
at lucee.runtime.compiler.CFMLCompilerImpl._compile(CFMLCompilerImpl.java:130)
at lucee.runtime.compiler.CFMLCompilerImpl.compile(CFMLCompilerImpl.java:76)
at lucee.runtime.PageSourceImpl._compile(PageSourceImpl.java:441)
at lucee.runtime.PageSourceImpl.compile(PageSourceImpl.java:408)
at lucee.runtime.PageSourceImpl.loadPhysical(PageSourceImpl.java:329)
at lucee.runtime.PageSourceImpl.loadPageThrowTemplateException(PageSourceImpl.java:237)

Pothys - MitrahSoft 
12 September 2019 at 13:44

I've checked this ticket & confirmed the issue happened on lucee 5.3.2.77 and the latest 5.3.5.5-SNAPSHOT. The nullpointer exception has been thrown when the cfcatch contains cfreturn. But, checked with ACF, it working as expected. It doesn't thrown any error.

Tim Parker 
11 September 2019 at 15:09

still crashes with 5.3.3.62

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 10 September 2019 at 17:05
Updated 1 July 2023 at 15:37