TritonDataCenter / node-stackvis

Stacktrace visualization tools
MIT License
338 stars 24 forks source link

RangeError: Maximum call stack size exceeded #12

Open despairblue opened 10 years ago

despairblue commented 10 years ago

When using the perf input format (stackvis perf < perf.data > flamegraph.htm) I always get:

$ stackvis perf < perf.data > flamegraph.htm  
{"name":"stackvis","hostname":"firefly","pid":7983,"level":40,"msg":"line 287: found empty line with no stack","time":"2014-06-12T14:03:59.906Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":7983,"level":40,"msg":"line 4638: unexpected end of stream","time":"2014-06-12T14:04:00.020Z","v":0}

/home/despairblue/node_modules/stackvis/lib/output-flamegraph-d3.js:83
                filecontents['rawdata'] = JSON.stringify(tree, null, '\t');
                                               ^
RangeError: Maximum call stack size exceeded
davepacheco commented 10 years ago

Would it be possible for you to run this with --abort-on-uncaught-exception (which should cause Node to dump core when this happens) and then make the core file available?

despairblue commented 10 years ago

Ehm, how exactly?

Doing stackvis --abort-on-uncaught-exception perf < perf.data > flamegraph.htm returns

usage: stackvis input-format output-format
or     stackvis share [FILENAME]

and stackvis perf --abort-on-uncaught-exception < perf.data > flamegraph.htm returns

Cannot find module './output---abort-on-uncaught-exception'
usage: stackvis input-format output-format
or     stackvis share [FILENAME]

and going through the node man page did not reveal such a flag, so I suppose it's an stackvis flag?

davepacheco commented 10 years ago

Try: node --abort-on-uncaught-exception $(which stackvis) < perf.data > flamegraph.htm

despairblue commented 10 years ago

Hey, sorry I've been busy with other projects.

The output is:

{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 278: unexpected blank line","time":"2014-07-29T10:38:57.421Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 286: unexpected blank line","time":"2014-07-29T10:38:57.426Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 287: unexpected blank line","time":"2014-07-29T10:38:57.426Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 3065: unexpected blank line","time":"2014-07-29T10:38:57.531Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 3067: unexpected blank line","time":"2014-07-29T10:38:57.532Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 4376: unexpected blank line","time":"2014-07-29T10:38:57.570Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 4448: unexpected blank line","time":"2014-07-29T10:38:57.572Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 4450: unexpected blank line","time":"2014-07-29T10:38:57.572Z","v":0}
{"name":"stackvis","hostname":"firefly","pid":26298,"level":40,"msg":"line 4638: unexpected end of stream","time":"2014-07-29T10:38:57.577Z","v":0}
davepacheco commented 10 years ago

No worries. That should have produced a separate core file, usually in the current directory. That's the file that would be useful.

despairblue commented 10 years ago

I'm unable to reproduce it with the perf data I have lying around at the moment. It produces a flamegraph.htm, but the file produces a javascript error.

Error: Invalid negative value for <rect> attribute height="-20" flamegraph.htm:1696
attrFunction flamegraph.htm:1696
d3_selectionPrototype.each flamegraph.htm:2099
d3_selectionPrototype.attr flamegraph.htm:1705
FlameGraph flamegraph.htm:9750
svInit flamegraph.htm:9513

Should I open a new issue?

davepacheco commented 10 years ago

Yeah, would you mind opening a separate issue for that? If you could post the data, that would help a lot.

davepacheco commented 10 years ago

From the data in #13, I can reproduce this and generate a core file. The stack is here:

804315c 0xbf27a3bf JSONSerialize (ac41db91)
    file: native json.js
    arg1: a47082f9 (SeqAsciiString)
    arg2: a7d589ad (JSObject)
    arg3: ac408081 (Oddball: "null")
    arg4: a7dde3ad (JSArray)
    arg5: 8828c0a5 (SeqAsciiString)
    arg6: 8828c0a5 (SeqAsciiString)
    posn: position 1800
80431c0 0xbf27aacc SerializeObject (ac41db6d)
    file: native json.js
    arg1: a7d589ad (JSObject)
    arg2: ac408081 (Oddball: "null")
    arg3: a7dde3ad (JSArray)
    arg4: 8828c0a5 (SeqAsciiString)
    arg5: 8828c0a5 (SeqAsciiString)
    posn: position 1030
80431f0 0xbf27a3bf JSONSerialize (ac41db91)
    file: native json.js
    arg1: a47082f9 (SeqAsciiString)
    arg2: a7dde205 (JSObject)
    arg3: ac408081 (Oddball: "null")
    arg4: a7dde3ad (JSArray)
    arg5: a47082f9 (SeqAsciiString)
    arg6: 8828c0a5 (SeqAsciiString)
    posn: position 1800
8043228 0xaa540f44 stringify (ac41dc21)
    file: native json.js
    arg1: a7d589ad (JSObject)
    arg2: ac408081 (Oddball: "null")
    arg3: 8828c0a5 (SeqAsciiString)
    posn: position 5089
8043254 0xbf287676 <anonymous> (as <anon>) (a7d58d0d)
    file: /opt/local/lib/node_modules/stackvis/lib/output-flamegraph-d3.js
    arg1: ac408081 (Oddball: "null")
    posn: position 2004
8043270 0xaa50f7a1 <ArgumentsAdaptorFrame>
8043294 0xbf283467 <anonymous> (as <anon>) (a7d5b981)
    file: /opt/local/lib/node_modules/stackvis/node_modules/vasync/lib/vasync.js
    arg1: ac408081 (Oddball: "null")
    arg2: ac408091 (Oddball: "undefined")
    posn: position 1389
80432b4 0xaa50f7a1 <ArgumentsAdaptorFrame>
80432d0 0xbf286977 <anonymous> (as <anon>) (a7d5bf05)
    file: /opt/local/lib/node_modules/stackvis/lib/output-flamegraph-d3.js
    arg1: ac408081 (Oddball: "null")
    arg2: a7d5d989 (JSObject)
    posn: position 1805
80432f0 0xbf28685a <anonymous> (as <anon>) (a7d62085)
    file: fs.js
    arg1: ac408081 (Oddball: "null")
    posn: position 7164
8043314 0xaa5141a5 <InternalFrame>
8043334 0xbf28561d <anonymous> (as <anon>) (a7d620c5)
    file: fs.js
    posn: position 3568

and it alternates between SerializeObject and JSONSerialize until it blows up. It doesn't appear to be a loop per se, in that arg1 is changing with each invocation. I think we just built up a JS object that was too deep to be serialized by JSON.stringify. That said, I'm not sure it's a valid structure:

> a7d589ad::jsprint -d8
{
    : {
        svUnique: 0,
        svTotal: 2,
        svChildren: {
            ???': {
                svUnique: 0,
                svTotal: 1,
                svChildren: {
                    ???': {
                        svUnique: 0,
                        svTotal: 1,
                        svChildren: {
                            k: {
                                svUnique: 0,
                                svTotal: 1,
                                svChildren: [...],
                            },
                        },
                    },
                },
            },
            y`/??': {
                svUnique: 0,
                svTotal: 1,
                svChildren: {
                    y`/??': {
                        svUnique: 0,
                        svTotal: 1,
                        svChildren: {
                            y`/??': {
                                svUnique: 0,
                                svTotal: 1,
                                svChildren: [...],
                            },
                        },
                    },
                },
            },
        },
    },
}

When I tune up the stack size, then I get an "unexpected end of stream" error and the program seems to hang for a while:

$ node --stack_size=1024 $(which stackvis) perf < perf.data > flame.htm
{"name":"stackvis","hostname":"370f60b7-8488-45a8-a8a6-a3716ee1b3ed","pid":33461,"level":40,"msg":"line 2853: unexpected end of stream","time":"2014-08-11T22:46:58.687Z","v":0}

@ackalker, could you take a look at this?

milosjovac commented 4 years ago

I know this is old by I'm facing the same problem. Any updates on the issue?

Data collected with: perf record -F99 -p 25565 -g -- sleep 3 Trying to generate .html with: stackvis perf < perf.data > flamegraph.html

The stackvis command for perf.data prints the following error:

{"name":"stackvis","hostname":"abc","pid":18409,"level":40,"msg":"line 119: unexpected end of stream","time":"2020-08-13T12:50:38.809Z","v":0}
TommyVV commented 1 year ago

I know this is old by I'm facing the same problem. Any updates on the issue?

Data collected with: perf record -F99 -p 25565 -g -- sleep 3 Trying to generate .html with: stackvis perf < perf.data > flamegraph.html

The stackvis command for perf.data prints the following error:

{"name":"stackvis","hostname":"abc","pid":18409,"level":40,"msg":"line 119: unexpected end of stream","time":"2020-08-13T12:50:38.809Z","v":0}

I got the same error , any updates ?

zeldrinn commented 1 year ago

i'm having the same issue as @milosjovac and @TommyVV, on stack profile from a process running node v10.16.3

saul-jb commented 11 months ago

I know this is an old issue but here is an answer for this for anyone still trying to do this with the same problem:

The stackvis command depends on text data not the raw binary that perf often outputs, so you need to convert it first:

perf script < perf.data > perf.txt

Or to convert from raw data to the graph in a single command:

perf script < perf.data | stackvis perf  > flamegraph.htm
ruben-grossmann commented 10 months ago

I know this is an old issue but here is an answer for this for anyone still trying to do this with the same problem:

The stackvis command depends on text data not the raw binary that perf often outputs, so you need to convert it first:

perf script < perf.data > perf.txt

Or to convert from raw data to the graph in a single command:

perf script < perf.data | stackvis perf  > flamegraph.htm

Thanks! I had the same problem as @zeldrinn, @milosjovac and @TommyVV and your solution works. Now I'm getting a weird chart:

image

But at least I'm getting something. Maybe I'm using the wrong parameters. I have to investigate further.