Closed Bug 533530 Opened 15 years ago Closed 13 years ago

junk training data not saved if plugin leaks, need a quit observer

Categories

(MailNews Core :: Filters, defect)

x86
Windows XP
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 8.0

People

(Reporter: rkent, Assigned: Bienvenu)

Details

(Keywords: dataloss)

Attachments

(1 file, 1 obsolete file)

While doing some testing for my extensions, I noticed that training data was not getting saved on shutdown. Data is supposed to be saved in the destructor for nsBayesianFilter, but that destructor was not getting called (presumably because of some sort of shutdown leak) which I confirmed with printf statements in the destructor.

While the shutdown leak seems to be caused by my extensions, still saving of training data is too important to rely on no leaks. We should add a quit observer to make sure that the data gets saved.
Severity: normal → critical
Keywords: dataloss
Summary: junk training data not saved if plugin leaks → junk training data not saved if plugin leaks, need a quit observer
I don't know if the issue is that the destructor isn't called. Even if it is called, it's too late to do things like NS_GetSpecialDirectory so training data won't get saved. I'm going to fix this, because I'm trying to fix the memory leaks from the xpcshell tests and test_junkingWhenDisabled leaks a lot of stuff.
Assignee: kent → dbienvenu
Attached patch proposed fix (obsolete) — Splinter Review
I need to add an Init method because you can't add observers in the constructor, because there are no references to the service yet, and it gets deleted out from under me when I add an observer. Init also has the nice advantage that you can actually return errors, though I haven't taken advantage of that.
Attachment #546949 - Flags: review?(kent)
Comment on attachment 546949 [details] [diff] [review]
proposed fix

clearing review request because I think this patch exposes issues w/ other tests
Attachment #546949 - Flags: review?(kent)
Attached patch minimal fixSplinter Review
minimal fix - I tried moving more stuff into Init() but got into a world of hurt that I don't feel like revisiting...
Attachment #546949 - Attachment is obsolete: true
Attachment #547109 - Flags: review?(kent)
Comment on attachment 547109 [details] [diff] [review]
minimal fix

The patch as listed does not work:

+NS_GENERIC_FACTORY_CONSTRUCTOR(nsBayesianFilter, Init)

should be

+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBayesianFilter, Init)

With that change, I tested this with printf's and with and without artificial leaks, and it seems to work.

r=me with that error fixed.
Attachment #547109 - Flags: review?(kent) → review+
thx for catching that! That would explain the weirdness I saw. Though I would have expected even more...

http://hg.mozilla.org/comm-central/rev/1bf028c0289b
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 8.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: