mshtml: suppress module unloading while gecko is loaded

Paul Bryan Roberts pbronline-wine at
Mon Dec 1 02:08:28 CST 2008

 > Dan Kegel wrote:
 > Thanks to Mike Hearn for pointing out that mshtml reference
 > counting was wrong, and Jacek for pointing out how to fix
 > it for now.
 > Once gecko is loaded, don't let mshtml unload.
 > This fixes a crash in starting Sketchup (bug 16164),
 > and probably fixes a number of other apps that
 > went pear-shaped after unloading mshtml...
Bug 14065 is another instance of the same thing.

I did a quick survey of DllCanUnloadNow() on the Wine 1.1.8 code base a 
couple of weeks ago ...

  55 DllCanUnloadNow routines (in some 272 dll subdirectories)

  11 FIXME stubs return S_FALSE
   7 FIXME stubs return S_OK

   3 without FIXME return S_FALSE
   2 without FIXME return S_OK

  32 appear to be real implementations

However, the first in the list (alphabetically) is in astream/main.c.  
It's reference counter (ddl_ref) is not incremented or decremented 
anywhere.  I count four pairs of inc/dec omissions.

In mshtml, I count 7 dll reference count inc/dec pairs, including the 
server lock pair, in main.c, htmldoc.c and protocol.c   I count 28 pairs 
of InterlockedDecrement / InterlockedIncrement calls around the creation 
/ destruction of active objects throughout the dll.  That would seem to 
imply 22 missing reference count inc/dec pairs.

If I finish my script, it will report how many pairs are missing for 
which dlls and in which source files, which might help make a decision 
whether the take up Mike Hearn's suggestion of never unloading 
anything.  Even that should involve work taking out the reference counts 
that are already there.

I do not see how the classic WinAPI regression tests can catch this kind 
of bug other than being a tautologous test of the creation/destruction 
all the known active objects.  If Mike Hearn's suggestion is not taken 
up, the script might also be useful for regression test purposes.


More information about the wine-devel mailing list