Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

NullReferenceException in OverloadResultComparer.Equals #286

Closed

Description

@lostmsu

There seems to be a recent regression in the commit c067e83 (does not appear to be directly caused by it though), that throws a NullReferenceException in

   at Microsoft.PythonTools.Analysis.BuiltinFunctionOverloadResult.get_Documentation()
   at Microsoft.PythonTools.Analysis.OverloadResultComparer.Equals(OverloadResult x, OverloadResult y)
   at Microsoft.PythonTools.Analysis.OverloadResult.Equals(Object obj)
   at System.Collections.Generic.ObjectEqualityComparer`1.Equals(T x, T y)
   at System.Collections.Generic.HashSet`1.Contains(T item)
   at System.Collections.Generic.HashSet`1.ContainsAllElements(IEnumerable`1 other)
   at Microsoft.PythonTools.Analysis.Infrastructure.EnumerableExtensions.SetEquals[T](IEnumerable`1 source, IEnumerable`1 other, IEqualityComparer`1 comparer)
   at Microsoft.PythonTools.Analysis.Values.BuiltinFunctionInfo.Equals(Object obj)
   at Microsoft.PythonTools.Analysis.ObjectComparer.Equals(AnalysisValue x, AnalysisValue y)
   at Microsoft.PythonTools.Analysis.AnalysisValue.Microsoft.PythonTools.Analysis.IAnalysisSet.Add(AnalysisValue item, Boolean& wasChanged, Boolean canMutate)
   at Microsoft.PythonTools.Analysis.Analyzer.TypedDependencyInfo.AddType(AnalysisValue ns)
   at Microsoft.PythonTools.Analysis.TypedDef`1.AddTypes(IVersioned projectEntry, IAnalysisSet newTypes, Boolean enqueue, IProjectEntry declaringScope)
   at Microsoft.PythonTools.Analysis.TypedDef`1.AddTypes(AnalysisUnit unit, IAnalysisSet newTypes, Boolean enqueue, IProjectEntry declaringScope)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.AssignImportedModuleOrMember(String name, IAnalysisSet value, Boolean addRef, Node node, NameExpression nameReference)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.FinishImportModuleOrMember(ModuleReference module, IReadOnlyList`1 attribute, String name, Boolean addRef, Node node, NameExpression nameReference)
   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.AnalysisUnit.Analyze(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)

I can not stably reproduce this issue, because I parse and queue modules in random order.

Activity

  1. lostmsu commented on Oct 24, 2018

    @lostmsu
    ContributorAuthor

    Mikhail Arkhipov (@MikhailArkhipov) it looks like I still get the same exception after rebasing on top of today's master. BTW, all this time I was able to work around it using this simple change: 15b64b2

  2. lostmsu commented on Oct 24, 2018

    @lostmsu
    ContributorAuthor

    Mikhail Arkhipov (@MikhailArkhipov) though the fact, that my commit causes the exception to disappear, means, that the problem is waaay deeper. It looks like _docTask is being accessed for read and write from different threads, which should not have happened in the first place.

  3. jakebailey commented on Oct 29, 2018

    @jakebailey
    Member

    Yeah, this doesn't seem to be fully fixed yet. #318

  4. MikhailArkhipov commented on Oct 29, 2018

    @MikhailArkhipov

    Thread race condition. BuiltinFunctionOverloadResult does

                    if (_docTask != null) {
                        _docTask.Wait(200);

    while task body is setting docTask to null. So between if and Wait docTask can become null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions