Search code examples
javacoldfusiondecompilingcoldfusion-8cfml

Coldfusion Runtime Source Code


Good Day,

I was wondering if it was possible to view/debug/hack into the coldfusion.runtime source code.

Specifically, I'm getting out of memory errors that look like the following:

allocLargeObjectOrArray: [C, size 8388624 
java.lang.OutOfMemoryError: allocLargeObjectOrArray: [C, size 8388624 at
java.util.Arrays.copyOf(Arrays.java:2882) at
java.io.CharArrayWriter.write(CharArrayWriter.java:105) at
coldfusion.runtime.CharBuffer.replace(CharBuffer.java:37) at
coldfusion.runtime.CharBuffer.replace(CharBuffer.java:50) at
coldfusion.runtime.NeoBodyContent.write(NeoBodyContent.java:254) at
[My Code]

I would like to know what the CharBuffer is replacing and why, what array it is copying and why, etc., so that I can tune my code.

My code cfloop's through a query and outputs its fields, including an 'IIf' statement and a 'de' function call.

I'm aware that I could tinker around with the code, and wait for it to crash again (or not), but I would prefer to see exactly what the problem is, rather than use trial and error.

Thank you.


Solution

  • The first option is to set HeapDumpOnOutOfMemoryError and then open the dump in JHAT to look for what is taking up the space. Given that the erroring code is attempting to copy a large buffer, there should be one already in memory. That ought to point you in the direction of the error

    You can almost certainly do the following, though if you want to:

    • Install Eclipse
    • Install one of the java decompilers which exist for it
    • Create a new project
    • Add cfusion.jar to the project
    • Read the code
    • Configure ColdFusion to listen to a port for debugging (-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044)
    • set up some breakpoints
    • set up a remote debugging session in eclipse, using the port above

    That ought to get you the ability to halt the thread as it errors and inspect the variables. Something in your code looks to be creating an 8.3 meg string. Being able to inspect the memory would probably help a lot.