Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] Boost-1.65.0 TlsSlot leak on win32
From: Klebsch, Mario (Mario.Klebsch_at_[hidden])
Date: 2018-03-20 07:23:35


Hi,

> How is your process exiting? Global destructors will only be called
> if execution leaves main/WinMain normally (without calling terminate,
> abort, _exit, TerminateProcess, throwing an exception, etc) -- and
> they'll (silently) stop being called if any destructor does throw an
> exception.

The process does not terminate. It just unloads the DLL.

> Also, unless you are dynamically unloading and reloading the DLL

That is what I (and our customer) is doing.

> (and dynamically unloading the DLL should trigger the destructors),

That is what I think, too.

I found, that _CRT_INIT() is called on load time to execute the constructors of global instances and that it is also called on unload time to execute destructors for global instances.

I put a breakpoint into the loop calling the destructors at unload time, and stepped into each of them. I found a lot of global destructors called, some for my global instances, others for boost::asio and other boost internal instances. But the destructor for those two win_tss_ptr<> instances does not seem to be in the list of destructors to call. :-(

> a *small* TLS slot leak is not that important as they are destroyed
> when your process exits anyway -- despite annoying AppVerifier. The
> main thing the checks are there for are if you are leaking TLS slots
> each time you call a particular method or something.

Our customer recently had a problem caused by a TLS slot leak in an old version of boost::thread. The customers application stopped working after about 50 minutes, just because a single TLS slot leaked on each library unload.

73, Mario


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net