CF9中的错误:由其他键引用和覆盖的唯一结构键的值

时间:2010-01-29 19:12:36

标签: coldfusion

我们遇到了CF9的严重问题,其中某些结构键的值可以被其他键引用,尽管其他键从未被设置。请参阅以下示例:

编辑:看起来它不仅仅是我们的服务器吃的东西。这是Adobe错误跟踪票证81884:http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=81884

编辑:正如已经指出的那样,Adobe推出了修复:http://kb2.adobe.com/cps/825/cpsid_82547.html

修补程序摘要指出,他们正在比较变量名称的哈希值而不是文字值,以获得速度。我不知道这会如何加快速度,但名称冲突的机会(尤其是较短的名字)应该是显而易见的。至少他们很快就能纠正。

<cfset a = { AO = "foo" } />
<cfset b = { AO = "foo", B0 = "bar" } />

<cfoutput>
The following should throw an error. Instead both keys refer to the same value.
<br />Struct a: <cfdump var="#a#" />
<br />a.AO: #a.AO#
<br />a.B0: #a.B0#
<hr />
The following should show a struct with 2 distinct keys and values. Instead it contains a single key, "AO", with a value of "bar".
<br />Struct b: <cfdump var="#b#" />

这对我们来说显然是一个完整的噱头。我很想知道是否有人遇到过这种情况或者可以在他们的环境中重现这一点。对我们来说,它在100%的时间内运行在Linux上运行的Apache / CF9上,包括RH4和RH5。我们在Java 1.6.0_14上使用默认的JRun安装。

为了查看问题的严重程度,我们运行了一个快速循环来查找受影响的其他命名序列,并找到了2个字母键名称的数百个匹配项。类似的循环在3个字母的名称中发现了更多的冲突。

<cfoutput>Testing a range of affected key combinations. This found hundreds of cases on our platform. Aborting after 50 here.</cfoutput>
<cfscript>
teststring = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
stringlen = len(teststring);
matchesfound = 0;
matches = "";

for (i1 = 1; i1 <= stringlen; i1++) {
    symbol1 = mid(teststring, i1, 1);
    for (i2 = 1; i2 <= stringlen; i2++) {
        teststruct = structnew();
        symbol2 = mid(teststring, i2, 1);
        symbolwhole = symbol1 & symbol2;
        teststruct[ symbolwhole ] = "a string";

        for (q1 = 1; q1 <= stringlen; q1++) {
            innersymbol1 = mid(teststring, q1, 1);
            for (q2 = 1; q2 <= stringlen; q2++) {
                innersymbol2 = mid(teststring, q2, 1);
                innersymbolwhole = innersymbol1 & innersymbol2;
                if ((i1 != q1 || i2 != q2) && structkeyexists(teststruct, innersymbolwhole)) {
                    // another affected pair of keys!
                    writeoutput ("<br />#symbolwhole# = #innersymbolwhole#");
                    if (matchesfound++ > 50) {
                        // we've seen enough
                        abort;
                    }
                }
            }
        }
    }
}
</cfscript>

再次编辑:这不仅影响结构键,还影响变量范围中的名称。至少变量范围存在引发错误的思想,“无法加载null”:

<cfset test_b0 = "foo" />
<cfset test_ao = "bar" />
<cfoutput>
test_b0: #test_b0#
<br />test_ao: #test_ao#
</cfoutput>

2 个答案:

答案 0 :(得分:6)

更新:HOTFIX发布: http://kb2.adobe.com/cps/825/cpsid_82547.html

我想是的,这是一个错误,但这是一个紧急解决方法:

<cfset a = createObject("java", "java.util.HashMap").init()>
<cfset structInsert(a, "AO", "foo") />

<cfset b = createObject("java", "java.util.HashMap").init()>
<cfset structInsert(b,"AO", "foo") />
<cfset structInsert(b,"B0", "bar") />

<cfoutput>
The following should throw an error. Instead both keys refer to the same value.
<br />Struct a: <cfdump var="#a#" />
<br />a.AO: #a.AO#
<br />a.B0: #a.B0#
<hr />

The following should show a struct with 2 distinct keys and values. Instead it contains a single key, "AO", with a value of "bar".
<br />Struct b: <cfdump var="#b#" />
</cfoutput>

由于struct是HashMap,你仍然可以使用CF中的所有struct函数。

同时,请在以下网址提交错误:http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html

答案 1 :(得分:0)

我发现更奇特的是它的作用:

<cfset b = { AO = "foo", BO = "bar"} />