Repository navigation
Fix Access crash on exit caused by VBE add-in command bar events - #98
Merged
Merged
Conversation
… exit The click event sinks of the VBE command bar buttons were never removed (unsubscribe was disabled for issue #77). The CLR finalizer then unadvised them during process shutdown, after the VBE was gone, which crashed Access (access violation in combase.dll/clr.dll). Office crash recovery restarted Access, leaving an empty Access window. Remove the click handlers in Dispose (not from the finalizer) before the AccUnit command bars are deleted, and unsubscribe the AccUnit sub menu CommandBarEvents in TestStarter. Buttons are still not deleted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With the AccUnit VBE add-in loaded and the VBA editor opened, closing Access crashed the process on every exit (5 of 5 runs). Sometimes Office crash recovery then restarted Access, which showed up as a new, empty Access window after closing.
Event log: access violation in
combase.dll, followed by.NET Runtimeevent 1023 (exit code80131506) and an access violation inclr.dll.Cause (from a full crash dump)
ComEventsInfo.Finalize→ComEventsSink.RemoveAll→ComEventsSink.Unadvise→ COM call marshalled into the main STA thread.CorExitProcess); dispatching the incomingUnadvisecall crashes incombase, because the VBE command bar objects are gone.ComEventsInfoand 17VbeCommandBarAdapter+CommandBarButtonAndClickHandler: theClickhandlers of the command bar buttons were never removed.VbeCommandBarAdapter.DisposeUnmanagedResourcesreturned early (issue #77) and the unsubscribe code was commented out.TestStarter.Disposealso only set_accUnitSubMenuEventsto null without removing itsClickhandler.Change
VbeCommandBarAdapter: newRemoveCommandBarButtonClickHandlers(), called fromDispose(true)only (never from the finalizer). Buttons are still not deleted (presumed reason for issue Test Explorer #77). Dead code removed.AccUnitCommandBarAdapter: removes the click handlers before deleting the AccUnit command bar and sub menu.TestStarter: removesOnAccUnitSubMenuEventsClickfrom_accUnitSubMenuEvents.Clickon dispose.Tested
AccessCodeLib.AccUnit.VbeAddIn.sln: passed.access-add-in/lib, no COM registration), process and event log monitored:Not changed (found on the way)
ComTools.GetOfficeComObjectByProgIDAndVBE:Marshal.BindToMoniker(fileName)can start a new Access instance if the file is not in the ROT, and its result is not checked against the VBE; ROT/GetActiveObjectcandidates and the pointers fromGetIUnknownForObject/QueryInterfaceinGetTypeForComObjectare not released.~VbeCommandBarAdapter(ReleaseComObject(VBE)on a shared RCW),~OfficeApplicationHelper,~Connect,~AccessErrorTrappingObserver(callsGetOption/SetOption).TestStarter: registered hotkeys are not unregistered on dispose.