Beware of Implicit Structs Bug in ColdFusion 9,0,1

This has been driving me nuts and I'm not sure how well documented this is, but I've stumbled across a bug in ColdFusion 9,0,1,274733 where implicit structs can end up as 'undefined' and crash your application.

I was working through an example from jQuery in Action, Second Edition (you know, because I was trying to figure something else out) when this happened to me again and I thought I would go ahead and share a simple way for others to test and let me know if it's happening to them.

Create a page called test.cfm and drop this code in it, point your browser to it and you'll probably see an error of 'Variable TERMS is undefined'.


<cfscript>
    if ( not IsDefined('term') ) {
        term = 'unknown';
    };
    term = lcase(term);

    terms = {
        'oil-tanned' = 'A method of leather tanning in which oils or fats are used to cure the leather. Such leather is usually very supple and has a matte or "oily" finish and is not generally polishable.',
        'full-grain' = 'Leather which has not been altered beyond hair removal. Full-grain leather is the most genuine type of leather, as it retains all of the original texture and markings of the original hide.',
        'vibram' = 'A brand of boot and shoe sole created by Vitale Bramani in the 1930s, orginally for climbing boots. They are easily identified by the distinctive yellow Vibram® octagon. The Vibram® brand is recognized worldwide as the leader in high performance soling products for outdoor, dress casual, and service footwear.',
        'goodyear welt' = 'The Goodyear welt is a method of attaching the sole of a shoe to the upper that is hand-stitched and allows multiple sole replacements, extending the life of the footwear.',
        'cambrelle' = ' A non-woven synthetic fabric used primarily as a lining for shoes, boots and slippers.',
        'cordura' = 'A certified fabric from INVISTA used in a wide range of products from luggage and backpacks to boots, to military wear and performance apparel. Cordura® is resistant to abrasions, tears and scuffs.',
        'gore-tex' = 'A water-proof and breathable fabric that offers superior insulating abilities in a light-weight fabric.',
        'stitch-down' = 'A method of boot construction that helps seal the boot against dirt, mud, and water and maximizes flexibility.',
        'unknown' = 'Unknown term.'
    };
</cfscript>
<cfoutput>#terms[term]#</cfoutput>

The funny thing is, if I move the code at the top of the page below the implicit struct, the page loads fine! Here's some code that should work now:


<cfscript>    
    terms = {
        'oil-tanned' = 'A method of leather tanning in which oils or fats are used to cure the leather. Such leather is usually very supple and has a matte or "oily" finish and is not generally polishable.',
        'full-grain' = 'Leather which has not been altered beyond hair removal. Full-grain leather is the most genuine type of leather, as it retains all of the original texture and markings of the original hide.',
        'vibram' = 'A brand of boot and shoe sole created by Vitale Bramani in the 1930s, orginally for climbing boots. They are easily identified by the distinctive yellow Vibram® octagon. The Vibram® brand is recognized worldwide as the leader in high performance soling products for outdoor, dress casual, and service footwear.',
        'goodyear welt' = 'The Goodyear welt is a method of attaching the sole of a shoe to the upper that is hand-stitched and allows multiple sole replacements, extending the life of the footwear.',
        'cambrelle' = ' A non-woven synthetic fabric used primarily as a lining for shoes, boots and slippers.',
        'cordura' = 'A certified fabric from INVISTA used in a wide range of products from luggage and backpacks to boots, to military wear and performance apparel. Cordura® is resistant to abrasions, tears and scuffs.',
        'gore-tex' = 'A water-proof and breathable fabric that offers superior insulating abilities in a light-weight fabric.',
        'stitch-down' = 'A method of boot construction that helps seal the boot against dirt, mud, and water and maximizes flexibility.',
        'unknown' = 'Unknown term.'
    };

    if ( not IsDefined('term') ) {
        term = 'unknown';
    };
    term = lcase(term);
</cfscript>
<cfoutput>#terms[term]#</cfoutput>

If I'm doing something wrong, please don't hesitate to point it out to me. Thanks!

Comments
Apparently, this bug only happens when using CFScript and works fine when using old school tag-based syntax (i.e., <cfif> <cfset>, etc.)
# Posted By Steve Withington | 1/13/11 4:33 PM
Odd, I can reproduce it with this small case:

<cfscript>
if ( not IsDefined('term') ) {
term = 'unknown';
};

terms = {};

</cfscript>
<cfset y = {name="foo"}>
<cfdump var="#variables#">

<cfdump var="#terms#">

# Posted By Raymond Camden | 1/13/11 4:39 PM
So get this: This will throw the bug (well not really since I'm just dumping Variables, but you get the idea):



<cfscript>
if (!IsDefined('term')) {
term = 'unknown';
};

terms = {};

</cfscript>
<cfdump var="#variables#">


but this WILL work right:



<cfscript>
if (!IsDefined('term')) term = 'unknown';

terms = {};

</cfscript>
<cfdump var="#variables#">

This smells like a parser error. Be sure to file a bug report.
# Posted By Raymond Camden | 1/13/11 4:42 PM
I found it. If you remove the ; at the end of the if clause, it should work perfectly. So this is bad:

if(...) { ... };

and this is good:

if(..) {..}
# Posted By Raymond Camden | 1/13/11 4:43 PM
@Ray,

that's bizzare ... i'll have to check, but i'm pretty sure i filed a bug report on this awhile back.

thanks for testing! :)
# Posted By Steve Withington | 1/13/11 5:15 PM
That is weird.

Is there a bug # on the bug tracker we can go vote on?
# Posted By Mark Mandel | 1/13/11 5:27 PM
I agree with Ray - this definitely feels like a parsing issue.
# Posted By Ben Nadel | 1/13/11 5:30 PM
@Mark, (et. al)

i couldn't find my original bug report so i submitted another one. feel free to vote on it: http://cfbugs.adobe.com

bug id: 85822
# Posted By Steve Withington | 1/13/11 8:18 PM
ColdFusion - Version 9,0,0,251028;
Edition - Developer ;
Web-Server - IIS;
Operating System - Windows XP;
Browser - Mozilla, IE

Result - Working fine
# Posted By sanoop | 1/14/11 12:12 PM
@sanoop: You are on CF900, not 901. Thats probably why it worked ok for you.
# Posted By Raymond Camden | 1/14/11 1:48 PM
Do you have a bug report link or bug number for this? I've lost quite a bit of time on this issue (see stackoverflow: http://stackoverflow.com/questions/6948541/odd-col...).

The issue was only on one of our nine servers which are all patched to the same version of ColdFusion.

I'd like to vote up the bug if one exists.

Thanks!

Aaron
# Posted By Aaron Greenlee | 8/11/11 5:54 PM
Just in case anyone else stumbles across this post, I've finally received an email from the Adobe ColdFusion Team which stated they were able to verify the bug.

The message indicated the fix is targeted for ColdFusion 10.0, Beta 1.

Cheers!
# Posted By Steve Withington | 9/26/11 8:56 PM
# Posted By Teri Quinn | 12/3/18 4:19 AM
As the financial pointers delineate Dubai as the focal point of business-related exercises in the UAE and the Middle East, there is no better an ideal opportunity to put resources into Dubai than NOW.
# Posted By business setup in dubai | 7/20/20 6:45 PM
This page is about a strategy for lessening the memory impression of projects in aggregated dialects with C-like structures - physically repacking these announcements for decreased size. To understand it, you will require fundamental information on the C programming language.
# Posted By Best Used Tires Shop | 10/30/20 12:16 PM
You have to know this procedure in the event that you expect to compose code for memory-compelled implanted frameworks for working framework portions. It is valuable in the event that you are working with application informational collections so enormous that your projects regularly hit memory limits.
# Posted By Auto Body Philadelphia | 10/30/20 12:18 PM
It is acceptable to know in any application where you ridiculously care about streamlining your utilization of memory data transfer capacity and limiting reserve line misses.
# Posted By Best Real Estate App | 10/30/20 12:19 PM
At long last, realizing this strategy is an entryway to other elusive C themes. You are not a serious C developer until you have gotten a handle on these guidelines. You are not an ace of C until you might have composed this report yourself and can censure it astutely.
# Posted By Dining Room Furniture Stores | 10/30/20 12:21 PM
Logozel is a platform where you can get Company Logo Design with the best-value rate, visit our website for more details
# Posted By Company Logo Design | 11/20/20 3:16 PM
This tip features something to know about when utilizing structures that ... Understood boxing happens again when the struct.
# Posted By Do My Homework For Me | 12/4/20 7:42 AM
Certain changes can shroud type-confuse bugs, where the objective sort doesn't ... You may be cautious with structure arrangements.
# Posted By Write My Dissertation | 12/4/20 7:43 AM
Pronounce struct at assemble time, in light of a cluster, understood # class name: bundle ... By that name is expressly characterized; in the last case, an admonition is given if the admonition.
# Posted By Do My Homework | 12/4/20 7:44 AM
Characterizing structs; accessing and refreshing structs; structs are exposed guides ... C File. Ex; know you may get a blunder saying the struct was not yet characterized if ... A structure joining the two fields with unequivocal default esteems, and certain nil esteems.
# Posted By Animated Video Production | 12/4/20 7:45 AM
Good article, but it would be better if in future you can share more about this subject. Keep posting
# Posted By Escorts in Delhi | 12/30/20 4:46 AM
I am impressed to see such professional work. A great job is done by the writer as requires a lot of effort and work. Seeing this I would definitely Buy Assignment Online from one of the reliable Professional assignment writing services in the UK.
# Posted By assignment writing help | 12/31/20 9:49 AM
In these days we haven’t only young collage girl escorts but also fallen our hands into exotic escorts. Our escorts in Delhi come to the prominence because of their venereal services and several other sexual features. People visit to us beholding various varieties in their heart and it’s our responsibility to set them to the edge. We put all efforts for your enjoyment because it’s like an exam of the fame we acquired in previous years. Delhi escorts girls are strictly trained to satisfy or handle each client they receive gently. There are the four categories mentioned below which are recently available here. You guys can take the pleasure of all these several services obtainable in Delhi.
http://www.escortsindelhie.in/high-profile-call-gi...
http://www.delhi-callgirls.in/get-lustful-memories...
# Posted By Delhi Call Girls | 3/10/21 2:50 AM
What’s Happening i am new to this, I stumbled upon this I have found It absolutely helpful and it has aided me out loads. I hope to contribute & aid other users like its helped me. Great job.
# Posted By lifestyle storage singapore | 12/11/21 4:39 AM
If you are a student you may need academic writing services, we provide the best Assignment Help Gold Coast at Speedycoursework.co.uk, which you should consider having at least once in your academic life.
# Posted By do my coursework for me | 7/15/22 10:30 AM

© 2023, Stephen J. Withington, Jr.  |  BlogCFC was created by Raymond Camden – Version 5.9.004

Creative Commons License  |  This work is licensed under a Creative Commons Attribution 3.0 Unported License.  |  Hosted by Hostek.com