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

Value cannot be null. Parameter name: key. #1611

Closed PeterMTaylor closed 8 years ago

PeterMTaylor commented 8 years ago

Received this error using the latest sync with rubberduck-vba/next. See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

\ Exception Text ** System.ArgumentNullException: Value cannot be null. Parameter name: key at System.Collections.Generic.Dictionary`2.Remove(TKey key) at Rubberduck.App.d28.MoveNext() in C:\Users\Peter\Dropbox\Doing\Github\Rubberduck\RetailCoder.VBE\App.cs:line 184 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b6_0(Object state)

retailcoder commented 8 years ago
        if (e.Item.HelpFile == null || e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
        {
            _logger.Debug("Locked project '{0}' was removed.", e.Item.Name);
            return;
        }

        var projectId = e.Item.HelpFile;
        _componentsEventsSinks.Remove(projectId); // <~ boom
        _referencesEventsSinks.Remove(projectId);
        _parser.State.RemoveProject(e.Item);

Weird, HelpFile being null means the project wasn't properly added in the first place. On it.

retailcoder commented 8 years ago

I think I might have forgot to reference this issue... can you get a repro with the latest build?

Stevefb commented 8 years ago

@retailcoder hi there - I think I got pretty much the same with the latest build.

Word crashed unexpectedly.... well I mean it's usually stable for a few minutes on a Monday morning ;-)

I'm not sure what caused this, I was not actually sitting at the PC at the time, came back to find:

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

\ Exception Text ** System.ArgumentNullException: Value cannot be null. Parameter name: key at System.Collections.Generic.Dictionary`2.Remove(TKey key) at Rubberduck.App.d32.MoveNext() in C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\RetailCoder.VBE\App.cs:line 213 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b6_0(Object state)

Hosch250 commented 8 years ago

The project ID is somehow null for these calls:

_componentsEventsSinks.Remove(projectId);
_referencesEventsSinks.Remove(projectId);

I wonder if it is because the project is already unloaded or something? No idea.

Stevefb commented 8 years ago

@Hosch250 My gut feeling is that it happens when a project is opened, or perhaps closed... I did get a crash when I had inspection results open then closed a project for which results were displayed. HTH

Hosch250 commented 8 years ago

When a project is removed.

Hosch250 commented 8 years ago

Can you give me the exact steps required to reproduce this? I tried opening two Excel instances and opened the VBE, then closed one Excel instance, and RD handled removing the component correctly--no crashes. Is this how you reproduced it, or is there another way?

Reference @Talorthain

Stevefb commented 8 years ago

Use MS Word.... On 22 Jun 2016 9:24 am, "Hosch250" notifications@github.com wrote:

Can you give me the exact steps required to reproduce this? I tried opening two Excel instances and opened the VBE, then closed one Excel instance, and RD handled removing the component correctly--no crashes. Is this how you reproduced it, or is there another way?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rubberduck-vba/Rubberduck/issues/1611#issuecomment-227601744, or mute the thread https://github.com/notifications/unsubscribe/AI6rV83S8mlxDGXiyO4_b-cZWPyJgp07ks5qOHLHgaJpZM4Io8qo .

Talorthain commented 8 years ago

Open excel

Go into vba editor

Change rubberduck settings (<-- settings issue tests from previous communications)

Exit from excel red X, without opening or creating a module or project

I am on Win10 pro, excel 2016 desktop

Regards

Anthony

From: Hosch250 [mailto:notifications@github.com] Sent: 22 June 2016 00:26 To: rubberduck-vba/Rubberduck Rubberduck@noreply.github.com Cc: Talorthain anthony_taylor7@btinternet.com; Mention mention@noreply.github.com Subject: Re: [rubberduck-vba/Rubberduck] Value cannot be null. Parameter name: key. (#1611)

Can you give me the exact steps required to reproduce this? I tried opening two Excel instances and opened the VBE, then closed one Excel instance, and RD handled removing the component correctly--no crashes. Is this how you reproduced it, or is there another way?

Reference @Talorthain https://github.com/Talorthain

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rubberduck-vba/Rubberduck/issues/1611#issuecomment-227601744 , or mute the thread https://github.com/notifications/unsubscribe/AGe015xmL1ka_3H8kB4bXdnxQSbS0sb4ks5qOHLqgaJpZM4Io8qo . https://github.com/notifications/beacon/AGe0123blN4WWhnWhOfPbsHMZOQuVN5eks5qOHLqgaJpZM4Io8qo.gif

Hosch250 commented 8 years ago

I still cannot verify this. I tried opening the VBE from Excel's default project page, and it creates a project by default. I tried adding new projects by opening the Start page, then closing it, but still no repro. I tried opening a single project from the start page, but it wouldn't let me open the VBE from there. Can you still reproduce this?

Talorthain commented 8 years ago

I will have a go tomorrow.

From: Hosch250 [mailto:notifications@github.com] Sent: 27 June 2016 18:57 To: rubberduck-vba/Rubberduck Rubberduck@noreply.github.com Cc: Talorthain anthony_taylor7@btinternet.com; Mention mention@noreply.github.com Subject: Re: [rubberduck-vba/Rubberduck] Value cannot be null. Parameter name: key. (#1611)

I still cannot verify this. I tried opening the VBE from Excel's default project page, and it creates a project by default. I tried adding new projects by opening the Start page, then closing it, but still no repro. I tried opening a single project from the start page, but it wouldn't let me open the VBE from there. Can you still reproduce this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rubberduck-vba/Rubberduck/issues/1611#issuecomment-228823734 , or mute the thread https://github.com/notifications/unsubscribe/AGe016Wq0qXMpW9VptAGu0irbQ52gUg0ks5qQA72gaJpZM4Io8qo . https://github.com/notifications/beacon/AGe013vjql_Mbwy4OZ-I618t8w5hWEHLks5qQA72gaJpZM4Io8qo.gif

Talorthain commented 8 years ago

capture

Installed newest version of Rubberduck Open excel Open VBA editor close vba editor from red x close excel from red x crash....

I dont create anything, open anything, add anything. I just open excel vba editor and close them down.

Hosch250 commented 8 years ago

Would one of you who can consistently reproduce this check whether the Code Explorer sees the project before it is removed? If Rubberduck doesn't know about it, I might as well just check for a null project and not try to remove it. If Rubberduck does know about the project, something is pretty seriously wrong.

Talorthain commented 8 years ago

crash on red x exit project identified rd ready

Installed newest version of Rubberduck Open excel Open VBA editor close vba editor from red x close excel from red x crash....

I dont create anything, open anything, add anything. I just open excel vba editor and close them down.

retailcoder commented 8 years ago

@Hosch250 that's the failing Debug.Assert call in the sink handler for project removed; Debug calls don't get compiled into a release build. How about we replace it with a conditional early return?

PeterMTaylor commented 8 years ago

@Hosch250 and @retailcoder I have be unable to reproduce this error regarding null with RD 2.0.3.0 build with Win 10 Home. Version 1511 and OS Build 10586.420. Attached are my three tests using ScreentoGif.

  1. with Word 2010 rd 2 0 3 0 word project test
  2. with Visio 2007 version I had rd 2 0 3 0 visio 2007 project test
  3. With Excel 2010. rd 2 0 3 0 excel project test
Talorthain commented 8 years ago

Just for clarity, I am using; win 10 detail excel version

Hosch250 commented 8 years ago

Has this been seen lately? I completely rewrote this part of the project a while ago.

retailcoder commented 8 years ago

Nope.