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: 10
Problem Description:
If a UDF is declared once and then shared by two threads that run it at the same time, it is not thread safe. The UDF keeps a reference to the page context where it was declared and the LocalScope.isEmpty() method is not thread safe.
Steps to Reproduce:
Tail your ColdFusion-out log while running this code
function udf() {}
cfloop( from="1", to="10000", index="i" ) {
thread name='test#i#' {
try {
udf();
} catch( any e ) {
writeDump( var=e.stacktrace, output="console" );
}
}
}
Actual Result:
After several runs, you'll see one or more threads throw this error, which will show in the console output.
java.util.ConcurrentModificationException
at java.base/java.util.HashMap$HashIterator.nextNode(Unknown Source)
at java.base/java.util.HashMap$EntryIterator.next(Unknown Source)
at java.base/java.util.HashMap$EntryIterator.next(Unknown Source)
at coldfusion.runtime.LocalScope.isEmpty(LocalScope.java:274)
at coldfusion.runtime.NeoPageContext.searchScopes(NeoPageContext.java:887)
at coldfusion.runtime.NeoPageContext.findAttribute(NeoPageContext.java:701)
at coldfusion.runtime.CfJspPage._get(CfJspPage.java:354)
at coldfusion.runtime.CfJspPage._get(CfJspPage.java:339)
at coldfusion.runtime.CfJspPage._get(CfJspPage.java:326)
at coldfusion.runtime.CfJspPage._get(CfJspPage.java:302)
at cfindex2ecfm1403424347$func_CFFUNCCFTHREAD_CFINDEX2ECFM14034243471.runFunction(C:\sandbox\adobeThreading\index.cfm:8)
Expected Result:
10,000 threads should run the UDF with no errors.
Any Workarounds:
Single thread the execution of the UDF, which of course, makes the threading moot.
Attachments:
Comments: