facebook / memlab

A framework for finding JavaScript memory leaks and analyzing heap snapshots
https://facebook.github.io/memlab/
MIT License
4.35k stars 118 forks source link

Heap data parsing failure #60

Closed enricoangelon closed 1 year ago

enricoangelon commented 1 year ago

Sample code I am using:

const head = await takeNodeMinimalHeap();
console.log(head.getAnyObjectWithClassName('Player'))

Stack trace:

calculating basic meta info... building reference index... building referrers index... propagating detachedness state... building node index... building location index... building extra meta info... identifying snapshot engine...

#
# Fatal error in , line 0
# Check failed: inference.RelyOnMapsViaStability(dependencies()).
#
#
#
#FailureMessage Object: 000000DABC5FDBE0
 1: 00007FF790AFACCF node_api_throw_syntax_error+175359
 2: 00007FF790A0EEAF std::basic_ios<char,std::char_traits<char> >::setstate+25487
 3: 00007FF791950FF2 V8_Fatal+162
 4: 00007FF791AE93B3 v8::internal::compiler::JSCallReducer::ReduceArrayBufferViewAccessor+1107
 5: 00007FF791AFBB41 v8::internal::compiler::JSCallReducer::ReduceJSCall+913
 6: 00007FF791AFAB63 v8::internal::compiler::JSCallReducer::ReduceJSCall+387
 7: 00007FF791AFA165 v8::internal::compiler::JSCallReducer::ReduceFunctionPrototypeCall+869
 8: 00007FF791AFB8E7 v8::internal::compiler::JSCallReducer::ReduceJSCall+311
 9: 00007FF791AFAB63 v8::internal::compiler::JSCallReducer::ReduceJSCall+387
10: 00007FF791AFAD49 v8::internal::compiler::JSCallReducer::ReduceJSCall+873
11: 00007FF791AE8D91 v8::internal::compiler::JSCallReducer::Reduce+113
12: 00007FF791A48537 v8::internal::compiler::Reducer::Reduce+39
13: 00007FF791A14E21 v8::internal::compiler::LiveRange::NextStart+10129
14: 00007FF791A48144 v8::internal::compiler::GraphReducer::Reduce+148
15: 00007FF791A487E6 v8::internal::compiler::GraphReducer::ReduceTop+358
16: 00007FF791A485D2 v8::internal::compiler::GraphReducer::ReduceNode+50
17: 00007FF791A19364 v8::internal::compiler::LiveRange::ResetCurrentHintPosition+6756
18: 00007FF791A09508 v8::internal::compiler::LoopPeeler::CanPeel+6472
19: 00007FF791A0AB15 v8::internal::compiler::LiveRange::End+2549
20: 00007FF791508191 v8::internal::OptimizedCompilationJob::ExecuteJob+49
21: 00007FF7914D6014 v8::internal::OptimizingCompileDispatcher::CompileNext+52
22: 00007FF7914D68C6 v8::internal::OptimizingCompileDispatcher::QueueForOptimization+726
23: 00007FF790A1190D X509_STORE_get_cleanup+813
24: 00007FF790B46E2D uv_poll_stop+237
25: 00007FF791C29960 inflateValidate+150576
26: 00007FFC212826BD BaseThreadInitThunk+29
27: 00007FFC2256DFB8 RtlUserThreadStart+40
JacksonGL commented 1 year ago

@HerryYT I suspect the issue is that when we use console.log to print out the node, the native API attempts to convert the entire heap's ArrayBuffer to a string, which can be quite large and causes an error in the node.js runtime. To confirm the theory, could you please try using the following code instead and see if it gets the same error?

const heap = await takeNodeMinimalHeap();
console.log(heap.getAnyObjectWithClassName('Player').name);
enricoangelon commented 1 year ago

I can confirm your theory.

parsing C:\Users\xxxx\AppData\Local\Temp\memlab-10864-1674325743401-1\nodejs-7124678321121458.heapsnapshot ...
calculating basic meta info...
building reference index...
building referrers index...
propagating detachedness state...
building node index...
building location index...
building extra meta info...
identifying snapshot engine...
Player