Re: More on the crash on exit.

From: Tomas Frydrych <tf_at_o-hand.com>
Date: Thu Jan 11 2007 - 09:49:00 CET

Martin Sevior wrote:
> On Thu, 2007-01-11 at 15:45 +1100, Martin Sevior wrote:
>> The crash on exit occurs with current AbiWord-2.5 on linux.
>>
>> It occurs because UT_ScriptLibrary::~UT_ScriptLibrary is called twice.
>>
>> This happens because if the are any plugins AT ALL UT_ScriptLibrary is
>> loaded as a plugin as well as being constructed via it's static instance
>> pointer.
>>
>> Upon closing AbiWord, all the plugins are unloaded, which deletes the
>> script library once. Then the application shuts downs and hence destroys
>> the UT_ScriptLibrary again through the static instance pointer and hence
>> the crash.
>>
>> I'm now trying to understand why the library gets loaded as a plugin,
>> which is the origin of the bug. However I've been chasing this bug for
>> several days so I my not be successful.
>>
>> If I hope this info will be valuable to someone else if I can;t find the
>> cause.
>>
>
> OK I fixed this by changing the access via reference to access via
> pointer.
>
> UT_ScriptLibrary is constructed in the XAP_App::initialize() method and
> UT_ScriptLibrary::instance() returns a pointer to the class.
>

Martin,

I fear that this merely covers up the real problem and introduces a new
one; the problem is not the reference, but that something is trying to
destroy an object that it does not own -- whatever has previously been
calling the destructor on the reference will now call it on the pointer.
If there is any code that has stored pointer to the singleton, that
pointer will be invalid. I think either the class should not be a
singleton if it makes sense to have more than one instance of it, or the
destructor should be private and invoked at most once when the whole
application is being destroyed.

Tomas
Received on Thu Jan 11 09:49:28 2007

This archive was generated by hypermail 2.1.8 : Thu Jan 11 2007 - 09:49:28 CET