Skip to content

Segmentation fault in native call binding.runInDebugContext #5217

Description

@akoskm

Hello!

I ran into this issue when I started using log4js with mongoose in node 4.3.0, so I'm not sure if there is an incompatibility or a bug. Because there is a Segmentation fault which I tracked down to a native call in node, I'm posting this here.

req.app.logger.debug('User created:', user);

When I'm trying to log this message - where the user is a Mongoose Document and logger is a log4js logger instance - here is what leads to the Segmentation fault, step by step:

At some point log4js calls formatLogData in util

function formatLogData(logData) {
  var data = Array.isArray(logData) ? logData : Array.prototype.slice.call(arguments);
  return util.format.apply(util, wrapErrorsWithInspect(data));
}

which accesses util.format https://github.com/nodejs/node/blob/master/lib/util.js#L48. This is from 5.6.0 but this line is the same for 4.3.0, basically, inspect(x) is called (x is the Mongoose Document).

Next call inside inspect: https://github.com/nodejs/node/blob/master/lib/util.js#L109 is formatValue, again, this is the same for both node versions.

Inside formatValue https://github.com/nodejs/node/blob/master/lib/util.js#L354 this happens:

var promiseInternals = inspectPromise(value);

https://github.com/nodejs/node/blob/master/lib/util.js#L199

which calls ensureDebugIsInitialized https://github.com/nodejs/node/blob/master/lib/util.js#L191

which leads to https://github.com/nodejs/node/blob/master/lib/vm.js#L38 where the whole thing explodes when in

exports.runInDebugContext = function(code) {
  return binding.runInDebugContext(code);
};

the native code binding.runInDebugContext(code); is called with "Debug".

node --version
v4.3.0

Edit
This issue happens only when node is started with --debug.

Activity

  1. mscdex commented on Feb 13, 2016

    @mscdex
    Contributor

    This issue should be fixed in the upcoming v4.3.1 LTS release.

    FWIW you can also test right now with rc2 if you want: https://nodejs.org/download/rc/v4.3.1-rc.2/

  2. added
    utilIssues and PRs related to the built-in util module.
    on Feb 13, 2016
  3. akoskm commented on Feb 13, 2016

    @akoskm
    Author

    Thanks for the quick response! When we can expect the 4.3.1 release, is there a roadmap for the LTS versions?

  4. mscdex commented on Feb 13, 2016

    @mscdex
    Contributor

    Right now it looks like the plan is to release on Tuesday.

  5. evanlucas commented on Feb 22, 2016

    @evanlucas
    Contributor

    Closing as v4.3.1 has been released. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions