DebuggerScript_getUrl crashes if script->filename is null

RESOLVED FIXED in mozilla15

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: jorendorff, Assigned: jorendorff)

Tracking

Other Branch
mozilla15
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [chrome-debug])

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
This definitely happens in the browser. We need a shell function that creates functions with null filenames in order to test it.
(Assignee)

Updated

5 years ago
Whiteboard: [chrome-debug]
(Assignee)

Comment 1

5 years ago
So I can't tell if we're actually supposed to support NULL filenames or not. The JSAPI documentation doesn't really say, but we don't JS_ASSERT(filename), and if we did I think we'd break Gecko.

So we probably should support NULL filenames, but there are no tests and in fact if I make it testable then I immediately get weird behavior:

js> evaluate("throw new Error()", {fileName: null});
js>

The error is never thrown. In fact creating the error object mysteriously fails, because of this code in jsexn.cpp:Exception():

669	            filename = FilenameToString(cx, iter.script()->filename);
670	            if (!filename)
671	                return false;

So basically this is a mess.
Assignee: general → nobody
Component: JavaScript Engine → js-ctypes
QA Contact: general → js-ctypes
Target Milestone: --- → mozilla14
Version: Other Branch → 15 Branch
(Assignee)

Comment 2

5 years ago
oh for the love of Mike
Assignee: nobody → general
Component: js-ctypes → JavaScript Engine
QA Contact: js-ctypes → general
Target Milestone: mozilla14 → ---
Version: 15 Branch → Other Branch
(Assignee)

Comment 3

5 years ago
OK, we definitely have null-filename scripts running around, because the patch in bug 738480 causes us to segfault when browser/devtools/commandline/test/browser_gcli_break.js tries to examine them.

Better to support this everywhere than to ban it... I guess? Any other JSAPI people care?
Blocks: 738480
(Assignee)

Updated

5 years ago
Assignee: general → jorendorff
(Assignee)

Comment 4

5 years ago
Created attachment 626690 [details] [diff] [review]
v1

This is gross. I'm convinced we should do away with null filenames, but let's stop the crashes first and do the API change in a different bug.
Attachment #626690 - Flags: review?(jimb)

Comment 5

5 years ago
Comment on attachment 626690 [details] [diff] [review]
v1

Review of attachment 626690 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great. One semi-nit; only change if you agree it's clearer.

::: js/src/jsexn.cpp
@@ +563,5 @@
>              return false;
>          args[1].setString(filename);
>      } else {
> +        const char *cfilename;
> +        if (!iter.done() && (cfilename = iter.script()->filename)) {

nit: Assignment operators in 'if' conditions aren't very legible. Could we perhaps:

filename = cx->runtime->emptyString;
if (!iter.done()) {
  const char *cfilename = iter.script()->filename;
  if (cfilename) {
    filename = FilenameToString(cx, cfilename);
    if (!filename)
      return false;
  }
}
Attachment #626690 - Flags: review?(jimb) → review+
(Assignee)

Comment 6

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/29a18a93721d
https://hg.mozilla.org/mozilla-central/rev/29a18a93721d
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla15
You need to log in before you can comment on or make changes to this bug.