Status/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): Bradley W. / ()
Created: 11/21/2019
Components: Language
Versions: 2016,2018
Failure Type: Data Corruption
Found In Build/Fixed In Build: Update 5 /
Priority/Frequency: Normal / Unknown
Locale/System: English / Platforms All
Vote Count: 12
Problem Description:
If a closure is declared once and then shared by two threads that run it at the same time, it is not thread safe. The Closure keeps a reference to the page context where it was declared and the NeoPageContext.popFunctionLocalScope() method is not thread safe.
Access to the function local scopes in the page context need to be synchronized for a given page context object. This error also happens on CF 2018 update 12 and CF 11 update 19
Steps to Reproduce:
Tail your ColdFusion-out log while running this code
application.udf = function() {}
cfloop( from="1", to="10000", index="i" ) {
thread name='test#i#' {
try {
application.udf();
} catch( any e ) {
writeDump( var=e.stacktrace, output="console" );
}
}
}
Actual Result:
Several of the threads will throw this error, which will show in the console output.
java.util.EmptyStackException
at java.base/java.util.Stack.peek(Unknown Source)
at coldfusion.runtime.NeoPageContext.popFunctionLocalScope(NeoPageContext.java:2089)
at coldfusion.runtime.Closure.invoke(Closure.java:133)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:447)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:398)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:371)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:287)
at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:4132)
at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:4112)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3604)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3561)
at cfindex2ecfm1403424347$func_CFFUNCCFTHREAD_CFINDEX2ECFM14034243471.runFunction(C:\sandbox\adobeThreading\index.cfm:11)
Expected Result:
10,000 threads should run the closure with no errors.
Any Workarounds:
Single thread the execution of the UDF, which of course, makes the threading moot.
Attachments:
Comments: