Skip to content

Language Server: System.ObjectDisposedException: PriorityProducerConsumer`1 instance is disposed #2387

Closed

Description

@derekwallace

Latest Insiders
vscode-pythong: 2018.8.0-alpha1

creating a new class the language server produced following to OUtput.

[Info - 7:14:27 AM] Found 28 completions for file:///p:/perforce_Playground/derekw_de02-1777_rce_dev/del.py at (13, 17) after filtering
[Error - 7:14:29 AM] System.ObjectDisposedException: PriorityProducerConsumer1 instance is disposed Object name: 'PriorityProducerConsumer1'.
at Microsoft.PythonTools.Analysis.Infrastructure.DisposeToken.ThrowIfDisposed()
at Microsoft.PythonTools.Analysis.Infrastructure.PriorityProducerConsumer`1.Produce(T value, Int32 priority)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.Enqueue(IAnalyzable item, AnalysisPriority priority)
at Microsoft.PythonTools.Analysis.LanguageServer.Server.OnDocumentChangeProcessingComplete(IDocument doc, VersionCookie vc, Boolean enqueueForAnalysis, AnalysisPriority priority, IDisposable disposeWhenEnqueued)

Code when crash happened
image

Outline is all wrong at the crash point.
image

Activity

  1. MikhailArkhipov commented on Aug 14, 2018

    @MikhailArkhipov
  2. AlexanderSher commented on Aug 14, 2018

    @AlexanderSher

    AnalysisQueue is disposed along with the server or when unhandled exception happens:

            private async Task ConsumerLoop() {
                RaiseEventOnThreadPool(AnalysisStarted);
                while (!_ppc.IsDisposed) {
                    try {
                        var item = await ConsumeAsync();
                        _current.Value = this;
                        await item.Handler(_ppc.CancellationToken);
                        _current.Value = null;
                    } catch (OperationCanceledException) when (_ppc.IsDisposed)  {
                        return;
                    } catch (Exception ex) when (!ex.IsCriticalException())  {
                        UnhandledException?.Invoke(this, new UnhandledExceptionEventArgs(ex, false));
                        Dispose();
                    }
                }
            }

    Server is subscribed to the AnalysisQueue.UnhandledException and calls Server_OnLogMessage. How do we handle it on VSC side?

  3. MikhailArkhipov commented on Aug 15, 2018

    @MikhailArkhipov

    LS dies I guess and then gets restarted by VSC.

  4. AlexanderSher commented on Aug 15, 2018

    @AlexanderSher

    So we don't have any traces of that exception?

  5. changed the title [-]Language Server: ystem.ObjectDisposedException: PriorityProducerConsumer`1 instance is disposed[/-] [+]Language Server: System.ObjectDisposedException: PriorityProducerConsumer`1 instance is disposed[/+] on Aug 16, 2018
  6. MikhailArkhipov commented on Aug 21, 2018

    @MikhailArkhipov

    I think I was disposed b/c of the crash and we fixed several. microsoft/PTVS#4645 may also help. I am going to close - please reactivate if you see it again.

  7. dc-avasilev commented on Sep 6, 2018

    @dc-avasilev
  8. brettcannon commented on Sep 6, 2018

    @brettcannon
    Member

    Andrey (@dc-avasilev) your issue isn't related to this one. It looks like there's a permission error where your files have file permissions that aren't permissible from the language server. Please open a separate issue and check that your files have file modifications for readability by anyone.

  9. rbu commented on Sep 7, 2018

    @rbu

    Still seeing this with the 2018.8.0 release (please reopen):

    [Error - 11:39:04 AM] System.ObjectDisposedException: PriorityProducerConsumer`1 instance is disposed
    Object name: 'PriorityProducerConsumer`1'.
       at Microsoft.PythonTools.Analysis.Infrastructure.DisposeToken.ThrowIfDisposed()
       at Microsoft.PythonTools.Analysis.Infrastructure.PriorityProducerConsumer`1.Produce(T value, Int32 priority)
       at Microsoft.PythonTools.Analysis.LanguageServer.Server.OnDocumentChangeProcessingComplete(IDocument doc, VersionCookie vc, Boolean enqueueForAnalysis, AnalysisPriority priority, IDisposable disposeWhenEnqueued)
    

    It's pretty annoying as it opens the output panel every few minutes while typing.

  10. dc-avasilev commented on Sep 7, 2018

    @dc-avasilev
  11. dc-avasilev commented on Sep 7, 2018

    @dc-avasilev
  12. brettcannon commented on Sep 7, 2018

    @brettcannon
    Member

    Andrey (@dc-avasilev) your issue is still off-topic for this issue. Please open a new issue.

  13. karingula commented on Sep 12, 2018

    @karingula

    same problem here :(

  14. fenchu commented on Sep 13, 2018

    @fenchu

    For me this happened after I upgraded WSL to a drvfs supported version, because it happens when saving file to a drfs drive. Earlier all WSL content had rwxrwxrwx file permissions. but the stack trace is terrible, no linenumbers, no external parameters.

  15. fenchu commented on Sep 13, 2018

    @fenchu

    I cleaned my workspace and installed vsc v1.27.1, the first time I press save I get the following:

    Starting Microsoft Python language server.
    Initializing for C:\dist\Python36\python.exe
    ##########Linting Output - pep8##########
    ##########Linting Output - pylint##########
    [Error - 9:41:00 AM] System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreter.ImportModule(String name)
       at Microsoft.PythonTools.Analysis.ModuleTable.TryImport(String name, ModuleReference& res)
       at Microsoft.PythonTools.Analysis.Analyzer.DDG.TryImportModule(String modName, Boolean forceAbsolute, ModuleReference& moduleRef, IReadOnlyList`1& remainingParts)
       at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(FromImportStatement node)
       at Microsoft.PythonTools.Parsing.Ast.FromImportStatement.Walk(PythonWalker walker)
       at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(SuiteStatement node)
       at Microsoft.PythonTools.Parsing.Ast.SuiteStatement.Walk(PythonWalker walker)
       at Microsoft.PythonTools.Parsing.Ast.PythonAst.Walk(PythonWalker walker)
       at Microsoft.PythonTools.Analysis.AnalysisUnit.AnalyzeWorker(DDG ddg, CancellationToken cancel)
       at Microsoft.PythonTools.Analysis.Analyzer.DDG.Analyze(Deque`1 queue, CancellationToken cancel, Action`1 reportQueueSize, Int32 reportQueueInterval)
       at Microsoft.PythonTools.Analysis.PythonAnalyzer.AnalyzeQueuedEntries(CancellationToken cancel)
       at Microsoft.PythonTools.Intellisense.AnalysisQueue.GroupAnalysis.Analyze(CancellationToken cancel)
       at Microsoft.PythonTools.Intellisense.AnalysisQueue.HandleAnalyzable(IAnalyzable item, AnalysisPriority priority, CancellationToken cancellationToken)
       at Microsoft.PythonTools.Intellisense.AnalysisQueue.ConsumerLoop()
    [Error - 9:41:00 AM] System.ObjectDisposedException: PriorityProducerConsumer`1 instance is disposed
    Object name: 'PriorityProducerConsumer`1'.
       at Microsoft.PythonTools.Analysis.Infrastructure.DisposeToken.ThrowIfDisposed()
       at Microsoft.PythonTools.Analysis.Infrastructure.PriorityProducerConsumer`1.Produce(T value, Int32 priority)
       at Microsoft.PythonTools.Intellisense.AnalysisQueue.Enqueue(IAnalyzable item, AnalysisPriority priority)
       at Microsoft.PythonTools.Analysis.LanguageServer.Server.OnDocumentChangeProcessingComplete(IDocument doc, VersionCookie vc, Boolean enqueueForAnalysis, AnalysisPriority priority, IDisposable disposeWhenEnqueued)
    
  16. MikhailArkhipov commented on Sep 13, 2018

    @MikhailArkhipov

    microsoft/python-language-server#68 was fixed.
    Null ref was fixed with microsoft/python-language-server#88. Closing pending release.

  17. locked as resolved and limited conversation to collaborators on Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions