Unsafe call to OleUninitialize in fpGUI's finalization section

Issue #4 resolved
rdipardo repo owner created an issue

HTML Tag 1.3 added a form component provided by the fpGUI toolkit. This library was chosen over the LCL to keep binaries lightweight.

I know from forum posts and other plugin projects that LCL components can be safely initialized and destroyed in the context of DllMain. Turns out that is not the case with fpGUI. Its components are specifically intended for standalone graphics applications, and include features provided by combase.dll, such as "drag and drop". To use the required COM libraries, the GDI wrapper calls OleInitialize and OleUninitialize (*1). Microsoft's documentation explicitly warns against calling these functions from DllMain, since

there is no way to control the order in which in-process servers are loaded or unloaded.

Sure enough, I noticed that a recent version of HTML Tag was making Notepad++ take slightly longer to shut down. The mouse cursor would spin for a second after the application window disappeared. The debugger found the problem in the DLL unloading phase; those brief pauses during shutdown were exception events like this one:

AppName notepad++.exe
AppVersion 8.4.4.0
AppTimeStamp 62d18e06
ModuleName combase.dll
ModuleVersion 10.0.22621.317
ModuleTimeStamp a0fb7b18
ExceptionCode c0000602
FaultingOffset 0000000000056f59
ProcessId 0x1d60
ProcessCreationTime 0x1d8b283b1f3819b
AppPath ..........
ModulePath C:\WINDOWS\System32\combase.dll
IntegratorReportId 06f1d928-e65c-432a-b407-ccdf84425b66
PackageFullName
PackageRelativeAppId

These crashes occur late in the application life-cycle and do not pose any risk to user data.

A bugfix release will appear soon.


(*1) https://github.com/graemeg/fpGUI/blob/1c0e3634fe59507b6e415119d861fbf06a8765d7/src/corelib/gdi/fpg_gdi.pas#L3345-L3347

Comments (1)

  1. Log in to comment