Issue 67511 - Destructor of spell checker implementation is never called
Summary: Destructor of spell checker implementation is never called
Status: CONFIRMED
Alias: None
Product: General
Classification: Code
Component: spell checking (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Linux, all
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-18 15:52 UTC by Achim Derigs
Modified: 2013-02-24 20:42 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
A simple spell checker test implementation (12.70 KB, patch)
2006-07-18 15:53 UTC, Achim Derigs
no flags Details | Diff
Update of the simple spell checker implementation. (9.51 KB, patch)
2006-08-03 16:44 UTC, Achim Derigs
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Achim Derigs 2006-07-18 15:52:22 UTC
The destructor of an implementation of service 
`com.sun.star.linguistic2.SpellChecker' is never called. It seems to me that 
service `com.sun.star.linguistic2.LinguServiceManager' doesn't free all 
references to such an implementation at Strg-Q (or File -> Exit). 
 
I've written a small implementation to demonstrate the behaviour (see 
attachment). It is a patch based on the CppComponent example. 
 
You will get the following output after clicking Tools -> Options... -> 
Language Settings -> Writing Aids: 
 
$ /usr/lib/openoffice/program/swriter 
Increment reference count: 1 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
queryInterface 
Increment reference count: 2 
com.sun.star.linguistic2.XSpellChecker 
Decrement reference count: 2 
queryInterface 
Increment reference count: 2 
com.sun.star.lang.XServiceInfo 
queryInterface 
Increment reference count: 3 
com.sun.star.linguistic2.XSupportedLocales 
getLocales 
Decrement reference count: 3 
Decrement reference count: 2 
Decrement reference count: 1 
dispose 
Increment reference count: 1 
Increment reference count: 2 
Decrement reference count: 2 
disposing 
Decrement reference count: 1 
~MyService2Impl 
----------------------------------------------- 
Increment reference count: 1 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
queryInterface 
Increment reference count: 2 
com.sun.star.lang.XInitialization 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
Increment reference count: 2 
Decrement reference count: 2 
queryInterface 
Increment reference count: 2 
com.sun.star.linguistic2.XSpellChecker 
Increment reference count: 3 
Decrement reference count: 3 
Decrement reference count: 2 
queryInterface 
Increment reference count: 2 
com.sun.star.lang.XServiceDisplayName 
getServiceDisplayName 
getLocales 
Increment reference count: 3 
Decrement reference count: 3 
 
Clicking Cancel and Strg-Q doesn't decrement the reference counter and 
therefore the destructor was never called.
Comment 1 Achim Derigs 2006-07-18 15:53:52 UTC
Created attachment 37869 [details]
A simple spell checker test implementation
Comment 2 Achim Derigs 2006-08-03 16:44:17 UTC
Created attachment 38244 [details]
Update of the simple spell checker implementation.
Comment 3 nemeth.lacko 2006-10-03 01:05:59 UTC
Thomas, It seems this issue is not a Lingucomponent problem, isn't it?
Comment 4 thomas.lange 2006-10-05 08:12:33 UTC
TL: reassigned to me.
Comment 5 thomas.lange 2006-10-05 09:09:44 UTC
Some things to take note of:
1) spellcheckers (usually) are one-instance services. That is when they get 
   created they live as long as the office (sometimes even longer!).
2) There can be cases where the d-tor does not get called. E.g. if in an
   external thread (e.g. by Java which has automatic garbage collection and
   thus may still keep references for some time) a reference to the 
   spellchecker is still is use while the office is shut down.
   (In that case later on a the d-tor might be called for an alrteady dead
   object.)
3) This may also be the case because of some progamming error. E.g. if the
   component would be created with new and thus by-passing the service 
   factory. This would result in the component being kept despite the
   reference count of the service factory going to 0.

In general (and especially including the above) relying on tje d-tor being
called to do to some required task is a bad choice anyway.
For these purpose the spellchecker implements the XComponent interface.
Any required clean-up, etc. should be done when dispose is called.

Because of this I must admit I did not check the issue by using your patch but
did only a quick check that 'dispose' gets called. This does happen.

Thus unless there is anything more serious involved I'll retarget this one to
'OOo later'.
Comment 6 thomas.lange 2006-10-05 09:10:01 UTC
.
Comment 7 thomas.lange 2006-10-05 09:12:09 UTC
TL: I can also confirm that the d-tor does not get called.
Comment 8 thomas.lange 2006-10-05 09:46:33 UTC
TL->Laccy: Thus if the d-tor SpellChecker::~SpellChecker() in sspellimp.cxx
really needs to execute it's code it should be moved.

(If it is only about freeing memory that could be left to the OS. Even though it
will be bad style there is no problem with it. That is: in this very case
nothing bad will happen even if the d-tor does not get called.)
Comment 9 nemeth.lacko 2006-10-05 12:56:53 UTC
Nemeth->TL: It is all right for me. Thanks. Laci