Friday, 12 July 2013

Yeah, so it wouldn't be my working week without another CF vs JSON issue

G'day:
Poor old me, and poor old Mockbox.

I just found this one when testing Mockbox 2.1. Testing it to see if we could upgrade to it (no, not until this is fixed). We already could not upgrade to 2.0 due to another issue (MOCKBOX-6), so on 1.3 we stay for the time being.

Both of these issues have been ColdFusion problems that Mockbox has been victim of though. Which sucks a bit for Luis & co.


Anyway, here's the latest one. It's quick and easy.

Consider this code:

function f(){

}

st = {
    f = f
};

s = serializeJson(st);

writeDump(variables);

Here I have a struct which has a function reference within it. And when I try to serialise that, I get a 500 error, and this in my exception.log:

"Error","jrpp-0","07/12/13","16:34:44",,"'' The specific sequence of files included or processed is: D:\websites\www.scribble.local\hb\mockbox\functionbug\serializeJsonBug.cfm'' "
java.lang.StackOverflowError
    at java.lang.Class.isInstance(Native Method)
    at coldfusion.runtime.dotnet.DotNetServiceImpl.isDotNetObject(DotNetServiceImpl.java:222)
    at coldfusion.runtime.StructBean.shouldConvertMethodsToFields(StructBean.java:367)
    at coldfusion.runtime.StructBean.getNames(StructBean.java:317)
    at coldfusion.runtime.Scope$ScopeSet.iterator(Scope.java:231)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:329)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:297)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:349)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:297)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:349)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:297)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:349)
    at coldfusion.runtime.JSONUtils.serializeJSON(JSONUtils.java:297)

And that goes on for about 140kB. This is on CF9.0.1.

On Railo it serialises OK, but as a struct. Now I have no expectations for this to work, but I don't expect it to cause a stack overflow.

I've just run it on CF10, and I get this:

{
    "F":{
        "REMOTE":3,
        "PACKAGE":2,
        "SuperScope":null,
        "PUBLIC":0,
        "Access":0,
        "MethodAttributes":[],
        "PagePath":"C:\\ColdFusion10\\cfusion\\wwwroot\\shared\\junk\\junk.cfm",
        "next":null,
        "Metadata":{
            "PARAMETERS":[],
            "NAME":"f"
        },
        "PRIVATE":1,
        "FunctionNameKey":{
            "SERIALIZABLE":{
                "SERIALIZABLE":{
                    "SERIALIZABLE":{
                        "SERIALIZABLE":{
                            "SERIALIZABLE":{
                                "SERIALIZABLE":{

(and that continues for another 120kB of "SERIALIZABLE")

So... err... don't try to serialise functions on ColdFusion, I guess!

I'll raise a bug: 3594386.

And then go to the pub.

--
Adam