Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault: 11 when debug Promise #4577

Closed
3y3 opened this issue Jan 8, 2016 · 12 comments
Closed

Segmentation fault: 11 when debug Promise #4577

3y3 opened this issue Jan 8, 2016 · 12 comments

Comments

@3y3
Copy link

3y3 commented Jan 8, 2016

Segfault happens when I try to use evaluate command in non stopped process, which logs Promise to console.
node - latest 4 and 5
os - darwin x64

app.js

setInterval(console.log, 100, new Promise(() => {}));

pseudo debugger:

require('net').connect('5858', function() {
  var data = JSON.stringify({
    "seq": 1,
    "type": "request",
    "command": "evaluate",
    "arguments": {
      "global": true,
      "expression": "global"
    }
  });

  this.write(`Content-Length: ${Buffer.byteLength(data, 'utf8')}\r\n\r\n${data}`);
});
$ node --debug app.js
$ node debugger.js

All works fine if process is paused or I don't try to log Promise:

setInterval(() => {
  var p = new Promise(() => {});
  console.log(''); // works fine
}, 100)

Encapsulated test:

var app = require('child_process')
  .exec('node --debug -e "setInterval(console.log, 10, new Promise(() => {}))"')
  .on('exit', () => console.assert(app.signalCode !== 'SIGSEGV', 'Segmentation fault'));

app.stderr.on('data', () => /* wait for `Debugger listening on port 5858`*/
  setTimeout(() =>
    require('net').connect('5858', function() {
      var data = JSON.stringify({
        "seq": 1,
        "type": "request",
        "command": "evaluate",
        "arguments": {
          "global": true,
          "expression": "global" /* global is accessible in global scope */
        }
      });

      this.write(`Content-Length: ${Buffer.byteLength(data, 'utf8')}\r\n\r\n${data}`);
    }), 300 /* small delay to initialize debugger in app */));
@mscdex
Copy link
Contributor

mscdex commented Jan 8, 2016

"node - latest 4 and 5" Can you be more specific about the exact versions you tried? 5.4.0 was just released the other day. Did you also try with the latest master branch?

@mscdex mscdex added the debugger label Jan 8, 2016
@davidvgalbraith
Copy link

I just tried the latest master branch -- can confirm segfault.

@davidvgalbraith
Copy link

Ah, sorry, the line .exec('node --debug -e "setInterval(console.log, 10, new Promise(() => {}))"') ran my global node which is behind master. Does not segfault when I replace that node with ./node, so I think this duplicates #4261.

@mscdex
Copy link
Contributor

mscdex commented Jan 8, 2016

I was able to duplicate it on OS X 10.10 with node v5.3.0, but not with v5.4.0.

Can you confirm @davidvgalbraith @3y3 ?

@davidvgalbraith
Copy link

I'm seeing the same thing @mscdex

@3y3
Copy link
Author

3y3 commented Jan 8, 2016

Ok, sorry, I miss release of 5.4. I can't confirm segfault on 5.4, but code doesn't work correctly:
I add console.log for response from app. I expect two messages:
connection info

Type: connect
V8-Version: 4.6.85.31
Protocol-Version: 1
Embedding-Host: node v5.4.0
Content-Length: 0

and evaluation result, but I receive only connection info.

var app = require('child_process')
  .exec('node --debug -e "setInterval(console.log, 10, Promise.all())"')
  .on('exit', () => console.log(app, app.signalCode !== 'SIGSEGV', 'Segmentation fault'));

app.stderr.on('data', () =>
  setTimeout(() =>
    require('net').connect('5858', function() {
      var data = JSON.stringify({
        "seq": 1,
        "type": "request",
        "command": "evaluate",
        "arguments": {
          "global": true,
          "expression": "global" /* global is accessible in global scope */
        }
      });

      this.on('data', (data) => console.log('' + data));

      this.write(`Content-Length: ${Buffer.byteLength(data, 'utf8')}\r\n\r\n${data}`);

    }), 300 /* small delay to initialize debugger in app */));

@3y3
Copy link
Author

3y3 commented Jan 8, 2016

@davidvgalbraith, @mscdex, is there any changes in debugger protocol in 5.4?

Is it possible to backport segfault fix in v4?

@3y3
Copy link
Author

3y3 commented Jan 8, 2016

I also see the difference in debugger statement behavior (difference between 0.10 and latest versions)
In latest versions debugger pauses program if it was started with --debug flag. In 0.10 this happens only in there exists connected debugger.
Is it expected behavior @indutny ?

@mscdex
Copy link
Contributor

mscdex commented Jan 8, 2016

@3y3 #4328 is already tagged for potential inclusion in v4.x.

@3y3
Copy link
Author

3y3 commented Jan 8, 2016

Ok, I'm ready to close this issue and open one other about stalled debugger #4577 (comment)
Or I can rename this issue.

@mscdex
Copy link
Contributor

mscdex commented Jan 8, 2016

@3y3 I would probably open a new issue and close this one.

@3y3
Copy link
Author

3y3 commented Jan 9, 2016

Ready #4597

@3y3 3y3 closed this as completed Jan 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants