nodejs / llnode

An lldb plugin for Node.js and V8, which enables inspection of JavaScript states for insights into Node.js processes and their core dumps.
Other
1.15k stars 100 forks source link

ECONNRESET using findrefs -s #267

Open Drieger opened 5 years ago

Drieger commented 5 years ago

I added test cases to the command findrefs -s and it happens that once in a while an ECONNRESET error is thrown.

Error: read ECONNRESET
    at exports._errnoException (util.js:1020:11)
    at Pipe.onread (net.js:580:26)

The following diff shows what was changed

diff --git a/test/fixtures/inspect-scenario.js b/test/fixtures/inspect-scenario.js
index fecd80c..af8d05a 100644
--- a/test/fixtures/inspect-scenario.js
+++ b/test/fixtures/inspect-scenario.js
@@ -84,9 +84,16 @@ function closure() {
     this.name = "Class B";
   }

+  function Class_C(arr) {
+    this.my_class_c = "My Class C";
+    this.arr = arr;
+  }
+
   const arr = new Array();
   for(let i=0; i < 10; i++) arr.push(new Class_B());

+  const class_c = new Class_C(arr);
+
   c.method();
 }

diff --git a/test/plugin/scan-test.js b/test/plugin/scan-test.js
index 0ec2b77..2aedfd4 100644
--- a/test/plugin/scan-test.js
+++ b/test/plugin/scan-test.js
@@ -79,12 +79,20 @@ function test(executable, core, t) {
     t.notOk(/\.\.\.\.\.\.\.\.\.\./.test(lines.join('\n')), 'Should not show ellipses');
     t.ok(/\(Showing 6 to 10 of 10 instances\)/.test(lines.join('\n')), 'Should show 6 to 10 ');

-    sess.send('v8 findjsinstances Zlib');
+    // sess.send('v8 findjsinstances Zlib');
+    sess.send('v8 findrefs -s "My Class C"');
     sess.send('version');
   });

   sess.linesUntil(versionMark, (err, lines) => {
     t.error(err);
+    t.ok(/(0x[0-9a-f]+): Class_C\.my_class_c=([0-9a-f]+)/.test(lines.join('\n')), 'Should find class C with string');
+    sess.send('v8 findjsinstances Zlib');
+    sess.send('version')
+  });
+
+  sess.linesUntil(versionMark, (err, lines) => {
+    t.error(err);
     // Find refs to every Zlib instance
     let found = false;
     for (let i = lines.length - 1; i >= 0; i--) {

To run the test until the error occurs the following script was used

while node test/plugin/scan-test.js;
do
  echo "good";
done

The error was reproduced in the following environment: Node.js version: v6.16.0 OS version: Ubuntu 16.04 Kernel: 4.15.0-43-generic #46~16.04.1-Ubuntu SMP Fri Dec 7 13:31:08 UTC 2018