Bug 2141 - Notification plugin segfaults on claws-mail exit if set to monitor a RSS-folder
Summary: Notification plugin segfaults on claws-mail exit if set to monitor a RSS-folder
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Plugins (show other bugs)
Version: 3.9.1
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2010-03-14 10:24 UTC by Andreas
Modified: 2012-12-09 18:19 UTC (History)
0 users

See Also:


Attachments
patch as described in my post (382 bytes, patch)
2010-03-14 10:29 UTC, Andreas
no flags Details | Diff

Description Andreas 2010-03-14 10:24:44 UTC
My situation:
I have the RSS plugin and the notification plugin. I want the notification plugin to give me a popup if a new message arrives in a RSS folder. This works great, until I exit claws mail, because then the following happens:
The function plugin_unload_all() in plugin.c is called
 --> the plugin list is reversed
 --> the RSS plugin will be unloaded
 --> the notification plugin should be unloaded
 --> the notification plugin tries to save the configuration
 --> the notification plugin tries to read the name of the rss folder
 --> segfault

If I comment the line where the plugin list is reversed it works fine (but probably breaks other things, I'm not aware of).

Attached is a patch, with the mentioned commented line ;)
Comment 1 Andreas 2010-03-14 10:29:47 UTC
Created attachment 824 [details]
patch as described in my post
Comment 2 Andreas 2010-03-14 11:30:10 UTC
I've investigated a bit further, and realized that my patch worked only by chance, because in my plugin list first the notification plugin is loaded and then the rss plugin.
If I change the order in clawsrc, I get of course the same segfault...
So this is probably something that needs to be fixed in the notification plugin...

This things should be fixed in the notification plugin (to work properly):
- Save configuration file, as soon as the configuration dialog is closed, not on unloading the plugin, because then it is not guaranteed that all folders still exist

- If a folder is not available on plugin loading, remember this folder and check again if new folders are added (happens if first notification plugin is loaded and then the RSS plugin). I do not know, if a plugin is notified if new folders are added, so this can happen to be somewhat complicated to implement...

Another possibility could give plugins a priority when they should be loaded, i.e. the rss plugin gets prioriy 1 and notification plugin priority 2. Then it works fine as it is at the moment...
Comment 3 Salvatore De Paolis 2010-03-14 16:05:18 UTC
Here as a temporary fix would be useful to use the API plugin_get_loaded_by_name (const gchar *name) introduced in Claws Mail 3.7.5cvs27
I say temporary because i don't know for how much time this API will live.
Comment 4 Andreas 2010-03-14 16:18:24 UTC
As I mentioned in comment #3 (maybe not clearly enough), I changed the order of the plugins in clawsrc to the order: VCalender, RSS, Notification.
This way I'm sure that first RSS registers the folders, and notification can monitor them.
On unloading the order is reversed, so first notification is unloaded (which does not segfault because RSS is still loaded), and then rss is unloaded.

This is a fix, which is rather hard to find for people without any coding knowledge...
Comment 5 Salvatore De Paolis 2010-03-14 17:04:22 UTC
That's not a fix, it's an hack that works only for you. You can't predict the order of loaded plugins.
The API i mentioned checks if a plugin is loaded or not, so using it in the notification would prevent to to refer to something that is already freed.
Comment 6 Colin Leroy 2010-03-14 17:42:52 UTC
Your solution isn't good either, because right now the notification plugin should check for RSS, Vcalendar, Mailmbox, maildir, etc.
Comment 7 Holger Berndt 2010-03-14 21:39:00 UTC
Can you describe exact steps to reproduce?
Comment 8 Andreas 2010-03-14 21:58:04 UTC
Here are the steps to reproduce:
1. Open ~/.claws-mail/clawsrc
2. In the section [Plugins_GTK2] these two lines should appear in that order:
/usr/lib64/claws-mail/plugins/notification_plugin.so
/usr/lib64/claws-mail/plugins/rssyl.so
(The order is important)
3. Open claws-mail
4. Configuration --> Preferences --> Plugins --> Notification --> Popup --> Select Folders
5. Select a folder which belongs to a RSS feed.
6. Close claws-mail and see the segfault

(7.) Change the order of notification_plugin.so and rssyl.so and see how it beautifully works (because of some magic, I described in comment #4)

Sidenote: The order of the plugins in clawsrc is determined on the order the plugins where first loaded in claws-mail. I.e. as in my case I first added the notification plugin, and later I added the RSS plugin...
Sidenote2: In comment #2 I've suggested 2 things which need to be considered ;)
Comment 9 Salvatore De Paolis 2010-03-14 22:23:15 UTC
What's not good with checking the state of several plugins when a plugin is potentially depended to all of them?
Comment 10 Andreas 2010-03-14 22:37:20 UTC
Because the notification plugin can't save it's config file if the plugin is already unloaded...
So the notification plugin needs to be modified to save the config file not when it is unloaded, but rather when the preferences dialog is closed.

So even if it would check whether a plugin is loaded it only supports to not segfault, but does not save a correct config file (but a modified notification plugin could of course save a correct config file)
Comment 11 Salvatore De Paolis 2010-03-14 23:30:41 UTC
I took a look in the code and i can see it better now.
Writing after closing the prefs dialog isnt a good way too, because i can later unload the RSS plugin which would result a broken config too.
The idea about giving an API to add a dependence while unload plugins is better but it requires changes in Claws Mail not in the plugin.
Comment 12 Salvatore De Paolis 2010-03-14 23:36:35 UTC
... which would crash again Claws Mail. Try to set the popup prefence as you did, that unload the plugin, than try again to check the popup preference. The result is a segfault.
That's why is needed to know if the plugin is loaded.
This is a discussion we already started in the devel mailing list, and surely require something better than plugin_get_loaded_by_name to deal with plugin dependencies.
Comment 13 Ricardo Mones 2012-12-03 16:54:33 UTC
This still happens on current CVS, so changing version accordingly.
Comment 14 Holger Berndt 2012-12-09 18:19:20 UTC
Fixed the crash by removing the possibility to select folders provided by other plugins. Claws Mail's current plugin infrastructure doesn't really provide the means to do that.

Note You need to log in before you can comment on or make changes to this bug.