rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 300 forks source link

Parse leaves "Ready" state, but empty CE #5021

Open daFreeMan opened 5 years ago

daFreeMan commented 5 years ago

Rubberduck version information

Version 2.4.1.4734
OS: Microsoft Windows NT 10.0.15063.0, x64
Host Product: Microsoft Office 2016 x64
Host Version: 16.0.4849.1000
Host Executable: EXCEL.EXE

Description I parsed the code, the status bar returned to "Ready", but the Code Explorer is blank and states Rubberduck doesn't see anything yet.

To Reproduce Steps to reproduce the behavior:

  1. Open a project in Excel
  2. Click on Ready/Parse button
  3. Wait for it to finish
  4. See error

Expected behavior When a parse completes, I'd expect to see the CE populated. If there's a parse error, I'd expect to be notified.

Logfile There are quite a number of NREs. Also quite a number of: Rubberduck.Parsing.VBA.RubberduckParserState;An exception occurred when notifying consumers of updated parser state.;System.AggregateException: One or more errors occurred. ---> System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.

RubberduckLog.txt

Additional context I had Excel open for about 3 days when this happened. It could well be a combination of that and some sort of local network glitch disconnecting me from the multiple XLSX & XLSM (all located on the network) that I had open. I won't be offended if this is closed as no-repo, but I figured I'd submit it on the off chance that someone might find something useful in the log and/or a better way of handling the errors reported.

Vogel612 commented 5 years ago

Exception sites in order of appearance in the stacktrace:

https://github.com/rubberduck-vba/Rubberduck/blob/4f387a27228c881a76258dce1aba8f35c73ed847/Rubberduck.Parsing/ComReflection/ComCoClass.cs#L44 https://github.com/rubberduck-vba/Rubberduck/blob/4f387a27228c881a76258dce1aba8f35c73ed847/Rubberduck.Parsing/VBA/ComReferenceLoading/COMReferenceSynchronizerBase.cs#L342

That exception happened when loading the Rubberduck TLB. This used to cause the Parser to not complete at all.

A handful of exceptions within the execution graph of a CanExecute invocation on a PrintCommand follow. They are thrown at this line: https://github.com/rubberduck-vba/Rubberduck/blob/4f387a27228c881a76258dce1aba8f35c73ed847/Rubberduck.Core/UI/CodeExplorer/Commands/PrintCommand.cs#L39

The options here are _projectsProvider being null or either Declaration or Declaration.QualifiedName returning null. Not quite sure which of these it is.

Then there is an exception in the ExportAllCommand pointing to https://github.com/rubberduck-vba/Rubberduck/blob/4f387a27228c881a76258dce1aba8f35c73ed847/Rubberduck.Core/UI/Command/ExportAllCommand.cs#L47

This makes very little sense, though...

Then there's quite a bunch of exceptions in the IndentCommand

https://github.com/rubberduck-vba/Rubberduck/blob/4f387a27228c881a76258dce1aba8f35c73ed847/Rubberduck.Core/UI/CodeExplorer/Commands/IndentCommand.cs#L49

This (in conjunction with the stacktrace) points to the declarations' DeclarationType being null. Both seem to make little sense, though, so I assume the line numbers within lambda expressions can be somewhat off.

All the other exceptions are repetitions of the different exceptions presented here already.

daFreeMan commented 5 years ago

See, I knew somebody would dig through it!

Interesting that there are issues in IndentCommand.cs - I almost never use the indenter since I usually do a reasonably good job of keeping up with indentation while I'm coding.

MDoerner commented 5 years ago

QualfiedName should not be able to return null since the return type is a struct.

MDoerner commented 5 years ago

The problem with the IndentCommand is in the EvaluateCanExecute method, which is triggered regularly. I think the exception only reports the starting line of the predicate. Probably, the NRE is in project.Declaration.ProjectId. This would imply that tge declaration is null.