Closed Bug 1013948 Opened 10 years ago Closed 10 years ago

Uncaught exception in task: `cm.lineInfo(...)` is null

Categories

(DevTools :: Debugger, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 957174

People

(Reporter: jlong, Unassigned)

References

Details

Not sure when or why this happens, but this pops up a few times now when running tests:

 0:55.32 *************************
 0:55.32 A coding exception was thrown and uncaught in a Task.
 0:55.32 
 0:55.32 Full message: TypeError: cm.lineInfo(...) is null
 0:55.32 Full stack: hasBreakpoint@resource://gre/modules/commonjs/toolkit/loader.js -> resource:///modules/devtools/sourceeditor/debugger.js:107:7
 0:55.32 addBreakpoint@resource://gre/modules/commonjs/toolkit/loader.js -> resource:///modules/devtools/sourceeditor/debugger.js:121:1
 0:55.32 Breakpoints.prototype._showBreakpoint@chrome://browser/content/devtools/debugger-controller.js:2112:9
 0:55.32 Breakpoints.prototype.updateEditorBreakpoints<@chrome://browser/content/devtools/debugger-controller.js:1842:50
 0:55.32 TaskImpl_run@resource://gre/modules/Task.jsm:282:13
 0:55.32 resolve@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/deprecated-sync-thenables.js:40:11
 0:55.32 then@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/deprecated-sync-thenables.js:20:43
 0:55.32 then@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/deprecated-sync-thenables.js:58:9
 0:55.32 TaskImpl_handleResultValue@resource://gre/modules/Task.jsm:334:1
 0:55.32 TaskImpl_run@resource://gre/modules/Task.jsm:290:11
 0:55.32 TaskImpl@resource://gre/modules/Task.jsm:247:3
 0:55.33 createAsyncFunction/asyncFunction@resource://gre/modules/Task.jsm:224:7
...
 0:55.33 *************************
Copied from bug 1018454 for posterity and cause it has STR.

(In reply to Nick Fitzgerald [:fitzgen] from bug 1018454 comment #0)
> STR: 
> 
> 1. Clone https://github.com/fitzgen/wu.js
> 2. Checkout 7bb63d89e15af1def9f0f86f5a421a038ef0fdb3
> 3. Open test-es5/test.html
> 4. Set a BP on test-enumerate.js line 4
> 5. Refresh
> 
> ER:
> 
> Hit the BP
> 
> AR:
> 
> Execution pauses like you hit the BP, but the stepping buttons are disabled
> like you didn't pause and you can't step.
> 
> This is what I'm seeing in the console:
> 
> """
> A promise chain failed to handle a rejection.
> 
> Date: Fri May 30 2014 18:00:28 GMT-0400 (EDT)
> Full Message: TypeError: cm.lineInfo(...) is null
> 
> debugger.js:107
> """
> 
> Which (for posterity) is the "let markers = ..." line here:
> 
> > function hasBreakpoint(ctx, line) {
> >   let { cm } = ctx;
> >   let markers = cm.lineInfo(line).gutterMarkers;
> > 
> >   return markers != null &&
> >     markers.breakpoints.classList.contains("breakpoint");
> > }
Assignee: nobody → nfitzgerald
Status: NEW → ASSIGNED
Tried just checking if the lineInfo was null and returning false, but that just moved the issue to line 137. Tried early returning again there and now there were no errors but the behavior quoted in comment 2 persists.

Need someone who understands code mirror better and can give insight into why cm.lineInfo() might be returning null in the first place.
Assignee: nfitzgerald → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(vporof)
Flags: needinfo?(bgrinstead)
Oddly, I do not see the error following STR on every reload, just some.  There are a couple of early returns in cm.lineInfo: http://dxr.mozilla.org/mozilla-central/source/browser/devtools/sourceeditor/codemirror/codemirror.js#3977.  In this case, `line` is definitely a number (4).  So the most likely issue I would think without digging really far into it is that the DOM for this.doc is not ready.
Flags: needinfo?(bgrinstead)
From the documentation, CM shouldn't return null for lineInfo. Maybe the |line| argument is out of bounds (like -1 or something)? Maybe it's a CM bug. Needs investigatin'.
Flags: needinfo?(vporof)
This also looks like bug 957174, but I'll keep it open while I'm investigating, as it has a lot of useful observations.
When I follow the STR from [1], it turns out that cm.lineInfo(6) is null, because cm.doc.first == 0 and cm.doc.size == 1. Not sure why that is happening yet.

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1022995#c4
When I break at codemirror.js:3979 after adding a couple of dump() calls to see the values I mentioned in the previous comment, things get crazy: inspecting cm.doc.size in the debugger shows a value of 12, even though the dump() call right before that prints 1!

The patch in bug 957174 seems to fix this set of STR too.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Blocks: 1011603
No longer depends on: 1011603
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.