ColdFusion Bug: CFTRACE and _CF_NODEBUG=true

Here is a interesting bug I ran into today while using CF No Debug. If you use the <cftrace> tag with the _cf_nodebug parameter set to true, the tag will throw the following error:

Variable DEBUGGER is undefined.

In ColdFusion, the <cftrace> tag is implemented in CFML via the pre-complied WEB-INF/cftags/trace.cfm template. Now, this is simply a guess, but I bet that trace.cfm uses the IsDebugMode() function to determine if it should attempt to write trace info to the debugging query. Possibly something like the following:

<cfif IsDebugMode()>
<cfset factory = CreateObject("java","coldfusion.server.ServiceFactory")>
<cfset debugger = factory.getDebuggingService().getDebugger()>
<!--- add trace data to debugger --->

As I previously noted there is a bug with IsDebugMode() where it returns true when using _cf_nodebug = true, even though the debugging service is disabled. If something like the above code is used in trace.cfm, IsDebugMode() would return a false positive when _cf_nodebug is true and the ColdFusion ServiceFactory would return null for the debugger variable. When a null value is assigned to a ColdFusion variable it can lead to the undefined error we see in this case.

I've logged a bug with Adobe for this, but it is something to look out for if you use CF No Debug and start seeing "Variable DEBUGGER is undefined" errors.

Adam Tuttle's Gravatar Good find!
# Posted By Adam Tuttle | 5/21/09 1:22 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.