Elliott's Blog | Life Through Math, Algorithms and Code

Sep/10

14

Some nasty CF9.0.1 Bugs

ColdFusion 9.0.1 added a lot cool features to CF9 and fixed quite a few outstanding bugs. Unfortunately it also introduces some really nasty bugs too and left a few hanging as well. Fortunately Adobe recently released the HotFix 1 for CF9.0.1 which fixes most of these bugs. If you’re currently on CF9.0.1 definitely install the 9.0.1 HF1! There’s no reason not to, and it’ll save you lots of pain later if you run across one of these bugs.

Despite fixing most of the outstanding bugs, there are still a few notable ones that might catch you off guard, and may cause some head scratching.

Cannot call function pointers in attributes scope

CF9 breaks calling function pointers you may have stored in the attributes scope. This breaks passing a function to a custom tag and calling it directly as attributes.myFunction(1,2,3) and will produce the error that the function “myFunction” doesn’t exist, even though if you dump that variable it certainly does. While an annoying bug, and certainly a regression from CF8, this is an easy bug to work around, just reassign the function to a local variable. Hopefully Adobe improves their test suite to exercise language features better so regressions like this can’t happen.

Operator precedence is wrong for implicit arguments

This bug is really nasty. The order in which implicit arguments are evaluated inside a boolean expression is wrong. The arguments are evaluated before the boolean expression is. A code example illustrates this bug better than a long explanation.

// Function that does nothing
function test() { return true; }

// Note that there's only THREE elements.
numbers = [1,2,3];

// Note that 3 gt 10 is always false, the function is NEVER called
// but CF will still try to access position 10 of numbers.
if( 3 gt 10 and test([numbers[10]]) ) 
{
	writeOutput("this never executes");
}

This code produces an index out of bounds error saying that the variable numbers has no element at position 10. This shows that the implicit array is being created before the function is called. This will catch you off guard if you use a boolean check in a while loop to protect array accesses so that they don’t go out of bounds. It also, more seriously, cause your code to produces side effects and execute code paths that you may not have expected because the first part of the boolean expression is false. Be really careful with this! Hopefully Adobe releases a HF2 since this bug really is bad.

While neither of these bugs should have happened with proper language testing, it’s really great to see that Adobe has been pushing forward with fixing so many language bugs in CF9. I put together a fairly comprehensive test suite to find language bugs in CF9 and these are the last two outstanding regressions now after CF9.0.1 HF1.

I’ll be releasing this test suite soon, and hopefully with that we’ll see the end of language regressions in CF10 (or dare to dream, CF9 HF2).

No tags

2 comments

  • Tony Nelson · September 14, 2010 at 5:17 pm

    I think your second example should be calling test() instead of func().

    Good stuff.

    Reply

  • Author comment by Elliott · September 17, 2010 at 5:52 pm

    @Tony

    Yeah you’re right. Fixed. Thanks for catching that.

    Reply

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me