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

Every now and then ctrl+alt+click does not open the editor #25580

Closed
alexdima opened this issue Apr 27, 2017 · 4 comments
Closed

Every now and then ctrl+alt+click does not open the editor #25580

alexdima opened this issue Apr 27, 2017 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority
Milestone

Comments

@alexdima
Copy link
Member

It takes a few attempts:

missing-editor

@alexdima
Copy link
Member Author

alexdima commented Apr 27, 2017

From a brief investigation it appears to me the following is happening:

  • the right hand side editor is called with setModel(aModel)
  • immediately, someone calls aModel.dispose().

I believe it is correlated with the fact that we show the hover, it appears that this model is created and disposed a lot! It appears that the hover stops showing in the left hand side editor, which then leads to the model being disposed even if the model is showing in the right hand side editor.

I have added log statements in the CommonCodeEditor.setModel and in Model.dispose:

model dispose was called on model file:///c%3A/Alex/src/vscode/src/vs/editor/common/editorCommon.ts
model.js:61 Error
    at Model.dispose (model.js:61)
    at ModelServiceImpl.destroyModel (modelServiceImpl.js:331)
    at TextFileEditorModel.BaseTextEditorModel.dispose (textEditorModel.js:148)
    at TextFileEditorModel.dispose (textFileEditorModel.js:720)
    at TextFileEditorModelManager.disposeModel (textFileEditorModelManager.js:308)
    at textModelResolverService.js:48
    at _Base.Class.derive._creator.CompletePromise_done [as done] (winjs.base.raw.js:1524)
    at ResourceModelCollection.destroyReferencedObject (textModelResolverService.js:46)
    at Object.<anonymous> (lifecycle.js:122)
    at Object.dispose (functional.js:27)

// the right hand side editor gets the model

commonCodeEditor.js:140 setModel was called with model file:///c%3A/Alex/src/vscode/src/vs/editor/common/editorCommon.ts
commonCodeEditor.js:141 Error
    at CodeEditor.CommonCodeEditor.setModel (commonCodeEditor.js:141)
    at textFileEditor.js:107
    at Object.notifySuccess [as _notify] (winjs.base.raw.js:1170)
    at Object.enter (winjs.base.raw.js:852)
    at _Base.Class.derive._creator._run (winjs.base.raw.js:1068)
    at _Base.Class.derive._creator._completed (winjs.base.raw.js:1036)
    at CompletePromise_ctor.CompletePromise_then [as then] (winjs.base.raw.js:1566)
    at Object.enter (winjs.base.raw.js:747)
    at _Base.Class.derive._creator._run (winjs.base.raw.js:1068)
    at _Base.Class.derive._creator._setCompleteValue (winjs.base.raw.js:1052)

// very quickly someone disposes this model, even if it is shown in an editor

model.js:60 model dispose was called on model file:///c%3A/Alex/src/vscode/src/vs/editor/common/editorCommon.ts
model.js:61 Error
    at Model.dispose (model.js:61)
    at ModelServiceImpl.destroyModel (modelServiceImpl.js:331)
    at TextFileEditorModel.BaseTextEditorModel.dispose (textEditorModel.js:148)
    at TextFileEditorModel.dispose (textFileEditorModel.js:720)
    at TextFileEditorModelManager.disposeModel (textFileEditorModelManager.js:308)
    at textModelResolverService.js:48
    at CompletePromise_ctor.CompletePromise_done [as done] (winjs.base.raw.js:1524)
    at ResourceModelCollection.destroyReferencedObject (textModelResolverService.js:46)
    at Object.<anonymous> (lifecycle.js:122)
    at Object.dispose (functional.js:27)

// the editor protects itself from disposed models by going to a null model

commonCodeEditor.js:140 setModel was called with model null
commonCodeEditor.js:141 Error
    at CodeEditor.CommonCodeEditor.setModel (commonCodeEditor.js:141)
    at commonCodeEditor.js:565
    at safeInvoke1Arg (eventEmitter.js:246)
    at OrderGuaranteeEventEmitter._emitEvents (eventEmitter.js:229)
    at OrderGuaranteeEventEmitter.EventEmitter.emit (eventEmitter.js:160)
    at Model.dispose (model.js:63)
    at ModelServiceImpl.destroyModel (modelServiceImpl.js:331)
    at TextFileEditorModel.BaseTextEditorModel.dispose (textEditorModel.js:148)
    at TextFileEditorModel.dispose (textFileEditorModel.js:720)
    at TextFileEditorModelManager.disposeModel (textFileEditorModelManager.js:308)

// unsure what the rest is, maybe I was running it two times

commonCodeEditor.js:140 setModel was called with model null
commonCodeEditor.js:141 Error
    at CodeEditor.CommonCodeEditor.setModel (commonCodeEditor.js:141)
    at TextFileEditor.clearInput (textFileEditor.js:186)
    at EditorPart.doHideEditor (editorPart.js:475)
    at EditorPart.doCloseGroup (editorPart.js:451)
    at EditorPart.doCloseActiveEditor (editorPart.js:434)
    at EditorPart.doCloseEditor (editorPart.js:421)
    at editorPart.js:414
    at _Base.Class.derive._creator.CompletePromise_then [as then] (winjs.base.raw.js:1566)
    at EditorPart.closeEditor (editorPart.js:409)
    at WorkbenchEditorService.doCloseEditor (editorService.js:132)
model.js:60 model dispose was called on model git:/c%3A/Alex/src/vscode/src/vs/editor/common/editorCommon.ts.git?%7B%22path%22%3A%22c%3A%5C%5CAlex%5C%5Csrc%5C%5Cvscode%5C%5Csrc%5C%5Cvs%5C%5Ceditor%5C%5Ccommon%5C%5CeditorCommon.ts%22%2C%22ref%22%3A%22%22%7D
model.js:61 Error
    at Model.dispose (model.js:61)
    at ModelServiceImpl.destroyModel (modelServiceImpl.js:331)
    at ResourceEditorModel.BaseTextEditorModel.dispose (textEditorModel.js:148)
    at textModelResolverService.js:51
    at _Base.Class.derive._creator.CompletePromise_done [as done] (winjs.base.raw.js:1524)
    at ResourceModelCollection.destroyReferencedObject (textModelResolverService.js:46)
    at Object.<anonymous> (lifecycle.js:122)
    at Object.dispose (functional.js:27)
    at Object.dispose (textModelResolverService.js:128)
    at lifecycle.js:27
model.js:60 model dispose was called on model file:///c%3A/Alex/src/vscode/src/vs/editor/common/editorCommon.ts
model.js:61 Error
    at Model.dispose (model.js:61)
    at ModelServiceImpl.destroyModel (modelServiceImpl.js:331)
    at TextFileEditorModel.BaseTextEditorModel.dispose (textEditorModel.js:148)
    at TextFileEditorModel.dispose (textFileEditorModel.js:720)
    at TextFileEditorModelManager.disposeModel (textFileEditorModelManager.js:308)
    at textModelResolverService.js:48
    at _Base.Class.derive._creator.CompletePromise_done [as done] (winjs.base.raw.js:1524)
    at ResourceModelCollection.destroyReferencedObject (textModelResolverService.js:46)
    at Object.<anonymous> (lifecycle.js:122)
    at Object.dispose (functional.js:27)
commonCodeEditor.js:140 setModel was called with model file:///c%3A/Alex/src/vscode/src/vs/editor/common/editorCommon.ts
commonCodeEditor.js:141 Error
    at CodeEditor.CommonCodeEditor.setModel (commonCodeEditor.js:141)
    at textFileEditor.js:107
    at Object.notifySuccess [as _notify] (winjs.base.raw.js:1170)
    at Object.enter (winjs.base.raw.js:852)
    at _Base.Class.derive._creator._run (winjs.base.raw.js:1068)
    at _Base.Class.derive._creator._completed (winjs.base.raw.js:1036)
    at CompletePromise_ctor.CompletePromise_then [as then] (winjs.base.raw.js:1566)
    at Object.enter (winjs.base.raw.js:747)
    at _Base.Class.derive._creator._run (winjs.base.raw.js:1068)
    at _Base.Class.derive._creator._setCompleteValue (winjs.base.raw.js:1052)
model.js:60 model dispose was called on model file:///c%3A/Alex/src/vscode/src/vs/editor/common/editorCommon.ts
model.js:61 Error
    at Model.dispose (model.js:61)
    at ModelServiceImpl.destroyModel (modelServiceImpl.js:331)
    at TextFileEditorModel.BaseTextEditorModel.dispose (textEditorModel.js:148)
    at TextFileEditorModel.dispose (textFileEditorModel.js:720)
    at TextFileEditorModelManager.disposeModel (textFileEditorModelManager.js:308)
    at textModelResolverService.js:48
    at _Base.Class.derive._creator.CompletePromise_done [as done] (winjs.base.raw.js:1524)
    at ResourceModelCollection.destroyReferencedObject (textModelResolverService.js:46)
    at Object.<anonymous> (lifecycle.js:122)
    at Object.dispose (functional.js:27)
commonCodeEditor.js:140 setModel was called with model null
commonCodeEditor.js:141 Error
    at CodeEditor.CommonCodeEditor.setModel (commonCodeEditor.js:141)
    at commonCodeEditor.js:565
    at safeInvoke1Arg (eventEmitter.js:246)
    at OrderGuaranteeEventEmitter._emitEvents (eventEmitter.js:229)
    at OrderGuaranteeEventEmitter.EventEmitter.emit (eventEmitter.js:160)
    at Model.dispose (model.js:63)
    at ModelServiceImpl.destroyModel (modelServiceImpl.js:331)
    at TextFileEditorModel.BaseTextEditorModel.dispose (textEditorModel.js:148)
    at TextFileEditorModel.dispose (textFileEditorModel.js:720)
    at TextFileEditorModelManager.disposeModel (textFileEditorModelManager.js:308)

@alexdima alexdima added this to the April 2017 milestone Apr 27, 2017
@bpasero bpasero added important Issue identified as high-priority bug Issue identified by VS Code Team member as probable bug labels Apr 28, 2017
@bpasero
Copy link
Member

bpasero commented Apr 28, 2017

Wow never saw this before, might be related to the adoption of ITextModelReference in FileEditorInput.

@bpasero
Copy link
Member

bpasero commented Apr 28, 2017

This is a race condition: both the hover and the editor ask for a model reference for editorCommon.ts at the same time. The hover receives a cached promise here because the editor is already resolving the reference shortly before from here. The hover is then being disposed, thus the model gets disposed.

@joaomoreno this seems very fragile to me. If there is anyone asking for a model reference while the model is being resolved, the ref counting is not working at all. Imho the promise caching needs to take ref counting into account, so if a second guy wants a reference for something that is being resolved already, the counter must still increment.

@joaomoreno
Copy link
Member

joaomoreno commented Apr 28, 2017

I didn't yet check the code. But:

The hover is then being disposed, thus the model gets disposed.

This doesn't sound right. The hover should dispose the reference it has to the model, not the model itself.

If there is anyone asking for a model reference while the model is being resolved, the ref counting is not working at all.

I can check that.

Edit: yup confirmed that there might be an issue there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority
Projects
None yet
Development

No branches or pull requests

4 participants