tracker issue : CF-3218452

select a category, or use search below
(searches all categories and all time range)

CFThread fails when called from Custom Tags without joining back to parent process

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Daniel Short / Daniel Short (Daniel Short)

Created: 06/19/2012

Components: Language, Tags

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: Final / 282610

Priority/Frequency: Critical / All users will encounter

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 2

Problem Description:

When a cfthread tag is used inside a custom tag, if the thread is not joined back to the calling custom tag, then the thread does not property execute.

Steps to Reproduce:

Create the following three files, all in the same directory.


{ = "CFThreadCustomTagTest";


<cfthread action="run" name="ThreadTestInPage">
    <cflog log="Application" text="The thread in the page successfully ran" type="information" />
<cf_ThreadTag />


<cfif thisTag.ExecutionMode EQ "start">
    <cfthread action="run" name="ThreadTest">
        <cflog log="Application" text="The thread within the tag successfully ran" type="information" />

Actual Result:

When viewing the logs, I see the following entries:

"Information","ajp-bio-8012-exec-1","06/19/12","07:18:11",,"C:\ColdFusion10\cfusion\logs\application.log initialized"
"Information","cfthread-11","06/19/12","07:18:15","CFTHREADCUSTOMTAGTEST","The thread in the page successfully ran"
"Error","cfthread-9","06/19/12","07:18:15",,"THREADTEST: Variable _cffunccfthread_cfThreadTag2ecfm16902001291 is undefined. "

Expected Result:

I expect to see two log entries, one for the thread processing in the page, and one for the thread processing in the tag. 

Any Workarounds:

If I change ThreadTag.cfm to the following code:

<cfif thisTag.ExecutionMode EQ "start">
    <cfthread action="run" name="ThreadTest">
        <cflog log="Application" text="The thread within the tag successfully ran" type="information" />
    <cfthread action="join" name="ThreadTest" timeout="10" />
    <cfdump var="#cfthread#">


Then I get the two log entries that I expect. However, I need to be able to run a thread without waiting for it to finish.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3218452


External Customer Info:
External Company:  
External Customer Name: webshorts
External Customer Email:  
External Test Config: My Hardware and Environment details:

Windows Server 2008, IIS 7 using the default ColdFusion 10 install. I have updated the JVM to u32 in order to be compatible with Microsoft's JDBC SQL Server driver. You can see my development server settings here:

I see this on three separate ColdFusion 10 installations, and can reproduce the problem every single time.



You can also see me working through this problem on StackOverflow here:
Comment by External U.
18965 | June 19, 2012 09:59:41 AM GMT
I was able to reproduce this using files provided by Dan S.
Vote by External U.
18970 | June 19, 2012 10:06:34 AM GMT
With further testing, I've found that if I move the thread logic into a CFC, and then run a CFC method from within the Custom Tag, that my thread runs and logs successfully. I change my custom tag to this: <cfif thisTag.ExecutionMode EQ "start"> <cfset myCFC = CreateObject("component", "myCFC") /> <cfset myCFC.runThread() /> </cfif> And create myCFC like so: <cfcomponent output="false"> <cffunction name="runThread" access="public" output="false" returntype="void"> <cfthread action="run" name="ThreadTest#CreateUUID()#"> <cflog log="Application" text="The thread within the CFC successfully ran" type="information" /> </cfthread> </cffunction> </cfcomponent> This allows the thread to run. So it is definitely a problem with thread running directly in the context of a custom tag exection.
Comment by External U.
18966 | June 19, 2012 10:29:34 AM GMT
Yep, I can replicate too.
Vote by External U.
18971 | June 20, 2012 07:00:21 AM GMT
We are still seeing this issue in CF 10 update 12. Why was this bug closed?
Comment by External U.
18967 | November 19, 2013 05:46:52 PM GMT
@ccapodilupo This was fixed in CF 10 update 1. Could you please share your repro case so that we can investigate?
Comment by Rupesh K.
18968 | November 29, 2013 03:31:49 AM GMT
I am seeing this error in CF10 update 13 when I call <cfthread> from inside a custom tag which is called from a CFC.
Comment by External U.
18969 | April 08, 2014 03:30:34 PM GMT
I just migrated an app from CF10 to CF2016,0,07,311392 and encountered this bug. I thought this was fixed? Here's a blog post that provides more info. (I believe that this is the same thing... the solution is the same.)
Comment by James M.
30128 | January 17, 2019 09:56:10 PM GMT