Skip to content

Segmentation fault in native call binding.runInDebugContext #5217

Closed
@akoskm

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.

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