|
Boost Users : |
From: Oliver (oliver.schoenborn_at_[hidden])
Date: 2005-09-08 21:35:28
Martin Ecker <martin.ecker <at> liwest.at> writes:
>>
>> Hi,
>>
>> Paolo Coletta wrote:
>
>>> > Is this expected to work? I made some tests and I got an access
>>> > violation when exiting the main app, in the destructor of
>>> > default_log_manager_impl(). (I can send a simple test case if needed).
>
>>
>> With the current implementation this won't work. The problem is that
>> the log instances do not unregister themselves from the log manager
>> upon destruction. So when the Boost Logging DLL gets unloaded it will
>> try to call a virtual destructor on all registered log instances, but
>> the corresponding vtable pointers could already be invalid if the DLL
>> that contains the logs has already been unloaded.
>>
>> I've already reported this problem to John. The fix for this is easy,
>> you have to unregister logs when they are destroyed, i.e. in their
>> destructor, from the log manager.
Could putting the initialization stuff in a class constructor, and instantiating
an object of that class before anything else in your main, be of any help? (if
there are any statics created, this will ensure they get created first, and
therefore, destroyed last). I had similar problems, and after doing this, the
crashes stopped. No guarantee of course since they were intermittent to start
with, and I don't know if DLL's are unloaded after all statics destroyed or
before or if it's even specified. Anyone know?
Oliver
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