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

::jsstack frame shows only one arg when two args were passed #89

Open
trentm opened this issue Jun 24, 2017 · 2 comments
Open

::jsstack frame shows only one arg when two args were passed #89

trentm opened this issue Jun 24, 2017 · 2 comments

Comments

@trentm
Copy link
Contributor

trentm commented Jun 24, 2017

Repro (sorry this is from running in an imgapi zone I have handy -- a smartos zone running node v4.6.1 with the verror module already installed):

[root@d934df7f-313d-470c-809b-8528fcefb51d (nightly-1:imgapi0) /opt/smartdc/imgapi]# cat boom.js
var WError = require('verror').WError;
var err = new WError({
        restCode: 'ResourceNotFound',
        statusCode: 404,
        constructorOpt: 'blah'
    }, '/docs/%2C%27%29..%28%28%28%2C%27');
[root@d934df7f-313d-470c-809b-8528fcefb51d (nightly-1:imgapi0) /opt/smartdc/imgapi]# node --abort-on-uncaught-exception  boom.js
XXX WError: arguments: {"0":{"restCode":"ResourceNotFound","statusCode":404,"constructorOpt":"blah"},"1":"/docs/%2C%27%29..%28%28%28%2C%27"}
Uncaught Error: too few args to sprintf

FROM
jsSprintf (/opt/smartdc/imgapi/node_modules/extsprintf/lib/extsprintf.js:71:4)
new WError (/opt/smartdc/imgapi/node_modules/verror/lib/verror.js:208:41)
Object.<anonymous> (/opt/smartdc/imgapi/boom.js:2:11)
Module._compile (module.js:409:26)
Object.Module._extensions..js (module.js:416:10)
Module.load (module.js:343:32)
Function.Module._load (module.js:300:12)
Function.Module.runMain (module.js:441:10)
startup (node.js:139:18)
node.js:974:3
Illegal Instruction (core dumped)

And from the core for that:

js:     WError
          file: /opt/smartdc/imgapi/node_modules/verror/lib/verror.js
          posn: line 194
          this: 8f06aa85 (JSObject: WError)
          arg1: 8f06aa65 (JSObject: Object)

            189 /*
            190  * Like JavaScript's built-in Error class, but supports a "cause" argument which
            191  * is wrapped, not "folded in" as with VError.  Accepts a printf-style message.
            192  * The cause argument can be null.
            193  */
            194 function WError(options)
            195 {
            196         Error.call(this);
            197 console.log('XXX WError: arguments: %j', arguments);
            198
            199         var args, cause, ctor;
            200         if (typeof (options) === 'object') {
            201                 args = Array.prototype.slice.call(arguments, 1);
            202         } else {
            203                 args = Array.prototype.slice.call(arguments, 0);
            204                 options = undefined;
            205         }
@trentm
Copy link
Contributor Author

trentm commented Jun 24, 2017

mdb_v8 version:

> ::load v8
mdb_v8 version: 1.1.4 (release, from 3a6fad0)
V8 version: 4.5.103.37
Autoconfigured V8 support from target
C++ symbol demangling enabled

@davepacheco
Copy link
Contributor

One problem is that the way we tell how many arguments were passed is by looking at how many arguments the function takes, which as I understand it is determined by the way the function is defined. In this case WError only nominally takes one argument here. In terms of doing better: the first question would be to figure out if the other arguments are actually there on the stack, or if they're stored elsewhere when there's a varargs situation like this. Relatedly, we need to determine if there is a way to tell how many arguments were actually passed.

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

2 participants