GNOME Bugzilla – Bug 546926
Camel should not use g_atexit
Last modified: 2013-09-14 16:52:40 UTC
Basically forwarding this from https://bugs.maemo.org/show_bug.cgi?id=3420 (refers to tinymail, but also fits for camel). http://svn.gnome.org/viewvc/evolution-data-server/trunk/camel/camel.c?revision=9171&view=markup : 51 camel_shutdown (void) 68 PR_Cleanup (); 142 g_atexit (camel_shutdown); http://maemo.org/api_refs/4.0/glib/glib-Miscellaneous-Utility-Functions.html#g-atexit Specifies a function to be called at normal program termination. ... The behaviour of atexit() in the context of dynamically loaded modules is not formally specified and varies wildly. On POSIX systems, calling g_atexit() (or atexit()) in a dynamically loaded module which is unloaded before the program terminates might well cause a crash at program exit. ... As can be seen from the above, for portability it's best to avoid calling g_atexit() (or atexit()) except in the main executable of a program.
I suggested in bug #445309 comment #148 that we make camel_shutdown() public and require that it be explicitly called. I think this is a stronger case for doing just that. In addition, I'd like to see camel_init() moved from mail_session_init() to main(), where we can easily add a symmetric call to camel_shutdown() after bonobo_main() returns, just prior to exiting.
also see bug 548325 about PR_Cleanup
Created attachment 116962 [details] [review] Proposed patch for Camel Makes camel_shutdown() public. It must now be called explicitly.
*** Bug 548325 has been marked as a duplicate of this bug. ***
Created attachment 116964 [details] [review] Proposed patch for Evolution Introduce mail_session_shutdown(), which calls camel_shutdown().
attachment 116962 [details] [review]: +camel_shutdown (void) + PR_Cleanup (); you're still going to call PR_Cleanup, bug 548325 asks you not to call PR_Cleanup. (Well, it might not, but really PR_Cleanup should only be called by a final application, and camel is a library which means it's the wrong place).
So better to just remove the PR_Cleanup() call entirely then?
+1
yes please
Consider it removed. No real need to post a revised patch.
changes are ok with me
Commit to trunk
Committed to trunk: EDS: revision 6411 Evo: revision 36029