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.92k stars 302 forks source link

System.AccessViolationException on Excel close #1710

Closed joshkreud closed 7 years ago

joshkreud commented 8 years ago

Getting this crash when trying to close excel:

Just open it add a module and try to close excel

image

private IntPtr WindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
        {
            try
            {
                var suppress = false;
                if (hWnd == _mainWindowHandle)
                {
                    switch ((WM)uMsg)
                    {
                        case WM.HOTKEY:
                            suppress = HandleHotkeyMessage(wParam);
                            break;

                        case WM.ACTIVATEAPP:
                            HandleActivateAppMessage(wParam);
                            break;
                    }
                }

                return suppress 
                    ? IntPtr.Zero 
                    : User32.CallWindowProc(_oldWndProc, hWnd, uMsg, wParam, lParam);
            }
            catch (Exception exception)
            {
                _logger.Error(exception);
            }

            return IntPtr.Zero;
        }
PeterMTaylor commented 8 years ago

Are you using 1.4 or the latest commit? If the latest there is a debug option in VS that can help point point where the code fails which is helping developers here

PeterMTaylor commented 8 years ago

See #1703

joshkreud commented 8 years ago

@PeterMTaylor Latest commit on next And well i could add a screenshot of the locals. The Callstack only shows [external Code] image

The last few Immediate Logs:

2016-06-06 08:01:19.3457;WARN;Rubberduck.Parsing.Symbols.TypeAnnotationPass;Failed to resolve type VBE;
Exception thrown: 'System.NotSupportedException' in Rubberduck.dll
Exception thrown: 'System.NotSupportedException' in Rubberduck.dll
Exception thrown: 'System.NotSupportedException' in Rubberduck.dll
comintern commented 8 years ago

This isn't the same issue as #1703. The hooks shouldn't be waiting for Dispose to detach themselves - it probably should simply be handled in the WindowProc when a WM_DESTROY is received.

retailcoder commented 8 years ago

@comintern #1780 fixed this, right?

comintern commented 8 years ago

@retailcoder - Didn't fix all the cases where you can end up with a zombie Excel, but it should close this specific access violation.

joshkreud commented 8 years ago

on commit: f0f830bbd2d2e96cf0a7de95332dfe9ebe84db20 this is still an issue open excel --> load rubberduck --> Close excel --> Exception

PeterMTaylor commented 8 years ago

With my fork in sync with https://github.com/rubberduck-vba/Rubberduck/commit/f0f830bbd2d2e96cf0a7de95332dfe9ebe84db20. I too got the open excel -> load rubberduck -> Close excel -> Exception.

Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Windows.Forms.dll
The program '[8096] Excel.exe' has exited with code -536870909 (0xe0000003).
retailcoder commented 7 years ago

deemed fixed at this point.