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 299 forks source link

Excel Crash after click Pending #2655

Closed SystemsModelling closed 7 years ago

SystemsModelling commented 7 years ago

This used to work but now I get a "Excel has stopped working" every time after clicking Pending. "Excel is trying to recover your work" Even on a small test workbook.

No Excel addins, no COM addins, MZTools not loaded, only Rubberduck. Last three lines in log file are

2017-02-07 15:27:58.1309;DEBUG-2.0.11.2453;Rubberduck.Parsing.VBA.ParseCoordinator;Binding resolution done for component 'testModule' in 242ms (thread 6); 2017-02-07 15:27:58.1499;DEBUG-2.0.11.2453;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'testModule' state is changing to 'Ready' (thread 6); 2017-02-07 15:27:58.2169;DEBUG-2.0.11.2453;Rubberduck.App;App handles StateChanged (Ready), evaluating menu states...;

SystemsModelling commented 7 years ago

I don't know if this is connected, but the last time RD worked, the last thing I did was to run Code Inspection, and for the first finding (Obsolete Let statement) I clicked Disable this inspection, and Excel crashed. RD hasn't worked since, as described above.

I've removed RD and reinstalled it, no difference.

comintern commented 7 years ago

You should have a file named rubberduck.config in your %appdata%\Rubberduck directory. Can you post the contents here?

SystemsModelling commented 7 years ago

Attached... rubberduck - Copy.config.txt

retailcoder commented 7 years ago

If you close the host, could there be an orphaned process stuck in limbo, in Task Manager?

SystemsModelling commented 7 years ago

I had rebooted.I'll try again tomorrow  On 7 Feb 2017 17:29, Mathieu Guindon notifications@github.com wrote:If you close the host, could there be an orphaned process stuck in limbo, in Task Manager?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

daFreeMan commented 7 years ago

@SystemsModelling - you may want to reconsider responding from your phone since it's posting your phone number in every comment.

On the other hand, you may not care...

SystemsModelling commented 7 years ago

I hadn't seen a problem with including my normal mobile email signature but as nobody else here uses sigs or personal photos as icons I guess it isn't the practice here. I'll remove it.

SystemsModelling commented 7 years ago

Just to check this morning: same thing. No Excel addins, COM addins, Action Packs, XML Expansion items, or VBE addins loaded on startup. Even on blank Book1: VBE Addins, Rubberduck, tick Loaded, OK, RD loads. Click Pending, gets as far as Resolving Declarations then Excel crash, RubberduckLog.txt

retailcoder commented 7 years ago

Wait you're loading RD after the VBE starts... that's a known highly problematic execution path. Repro with RD loaded along with the VBE?

SystemsModelling commented 7 years ago

Yes. I tried it both ways. On 08/02/2017 12:18, Mathieu Guindon wrote:

Wait you're loading RD after the VBE starts... that's a known highly problematic execution path. Repro with RD loaded /along/ with the VBE?

retailcoder commented 7 years ago

Hmm I mean we have a known serious issue with reloading the addin via the IDE's AddIns menu... best avoid that menu :-)

SystemsModelling commented 7 years ago

So to be clear: If I want to use RD, tick "Load on startup" and restart Excel If I want to unload RD, untick "Load on startup" and restart Excel

retailcoder commented 7 years ago

Yep. Until we figure out how to fix the teardown issues, at least.

SystemsModelling commented 7 years ago

OK. FYI I also deleted all the files in AppData\Local\Temp (except for locked by Thunderbird)

At the moment this is a blocking issue, I can't use RD.

comintern commented 7 years ago

I seem to have stumbled onto a repro of this while investigating #2653. It's acting like the component sink registration is persisting somehow when the host is closed. The exception that is taking down RD is the one from the screenshot in that issue. Specifically, here in VBComponent.cs:

    private void ExportDocumentModule(string path)
    {
        var lineCount = CodeModule.CountOfLines;
        if (lineCount > 0)
        {
            var text = CodeModule.GetLines(1, lineCount);
            File.WriteAllText(path, text);    //<-- Boom.
        }
    }
retailcoder commented 7 years ago

That's my error (again!) - file I/O without a try/catch... slaps wrist

SystemsModelling commented 7 years ago

I don't understand how RD worked for a few days and now this showstopper happens. Is there anything else in the environment or setup that could have changed which I have not thought of yet?

UPDATE: I uninstalled, rebooted, checked for no Rubberduck files (other than logs), no Rubberduck mentions in Registry, reinstalled, rebooted, and now it's working again.

I'll be back :-)

wsrob commented 7 years ago

Just came across Rubberduck and ran into this same issue that @SystemsModelling mentioned with the same repro. I'm using it in Access 2016.

"I don't know if this is connected, but the last time RD worked, the last thing I did was to run Code Inspection, and for the first finding (Obsolete Let statement) I clicked Disable this inspection, and Excel crashed. RD hasn't worked since, as described above."

wsrob commented 7 years ago

This line throws a nullref. This is in 2.0.11 (just downloaded it with source today)

var results = (await _inspector.FindIssuesAsync(_state, CancellationToken.None)).ToList();

The Access database is not that big and has the standard references plus Office 16.0 and a VBE reference.

Here's the callstack

` [External Code]

Rubberduck.dll!Rubberduck.UI.Inspections.InspectionResultsViewModel.RefreshInspections() Line 263 C# Rubberduck.dll!Rubberduck.UI.Inspections.InspectionResultsViewModel._state_StateChanged(object sender, System.EventArgs e) Line 254 C# Rubberduck.Parsing.dll!Rubberduck.Parsing.VBA.RubberduckParserState.OnStateChanged(object requestor, Rubberduck.Parsing.VBA.ParserState state) Line 284 C# Rubberduck.Parsing.dll!Rubberduck.Parsing.VBA.RubberduckParserState.Status.set(Rubberduck.Parsing.VBA.ParserState value) Line 485 C# Rubberduck.Parsing.dll!Rubberduck.Parsing.VBA.RubberduckParserState.SetModuleState(Rubberduck.VBEditor.SafeComWrappers.Abstract.IVBComponent component, Rubberduck.Parsing.VBA.ParserState state, Rubberduck.Parsing.Symbols.SyntaxErrorException parserError) Line 330 C# Rubberduck.Parsing.dll!Rubberduck.Parsing.VBA.ParseCoordinator.ResolveReferences(Rubberduck.Parsing.Symbols.DeclarationFinder finder, Rubberduck.VBEditor.SafeComWrappers.Abstract.IVBComponent component, Antlr4.Runtime.Tree.IParseTree tree) Line 660 C# Rubberduck.Parsing.dll!Rubberduck.Parsing.VBA.ParseCoordinator.ResolveReferencesAsync.AnonymousMethod__1() Line 318 C# [External Code]

`

comintern commented 7 years ago

@wsrob - Can you post the directory listing from your Rubberduck install directory? I'm curious if there are any temp files left over in there.

wsrob commented 7 years ago

Thanks for the response @comintern . I uninstalled RD so the only rubberduck.dll and registry settings are the one that I built in VS2015 and added manually. My RD.dll is here:

Rubberduck-2.0.11\Rubberduck-2.0.11\RetailCoder.VBE\bin\Debug\Rubberduck.dll

Is there another place I should look? There is no \rubberduck folder under \Program Files and \Program Files (x86)

comintern commented 7 years ago

@wsrob - Nope that would be the one. If you're running a local build, I'd suggest cloning the current source code from the repo and building current - there are a ton of bug fixes and thread safety improvements that could be relevant to your crash. I'm guessing your issue is tangential to this one. If it still pops up with the current source, I'd open a new issue for it.

retailcoder commented 7 years ago

@comintern are the temp files created in the install folder? The installer runs with admin privs but not necessarily the host process.. seems a non-admin user could be getting IOExceptions on parse if the temp files are under Program Files, no? ...we should be creating these files in the %temp% folder...

comintern commented 7 years ago

@retailcoder IIR the temp files the parser spits just go into the folder that the assembly is executing from. We should definitely be using the temp folder and requesting temp filenames from the OS.

wsrob commented 7 years ago

Thanks again @comintern . I forked the project and ran it locally and it works with the latest bits (2.0.12.36107)

I hit a new issue though that I'll open (after looking for it first).