After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 546926 - Camel should not use g_atexit
Camel should not use g_atexit
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: Mailer
2.24.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: evolution-mail-maintainers
Evolution QA team
: 548325 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-08-08 11:47 UTC by André Klapper
Modified: 2013-09-14 16:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch for Camel (1.85 KB, patch)
2008-08-19 14:07 UTC, Matthew Barnes
committed Details | Review
Proposed patch for Evolution (1.77 KB, patch)
2008-08-19 14:11 UTC, Matthew Barnes
committed Details | Review

Description André Klapper 2008-08-08 11:47:23 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.
Comment 1 Matthew Barnes 2008-08-08 12:08:45 UTC
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.
Comment 2 André Klapper 2008-08-18 19:26:22 UTC
also see bug 548325 about PR_Cleanup
Comment 3 Matthew Barnes 2008-08-19 14:07:12 UTC
Created attachment 116962 [details] [review]
Proposed patch for Camel

Makes camel_shutdown() public.  It must now be called explicitly.
Comment 4 Matthew Barnes 2008-08-19 14:07:56 UTC
*** Bug 548325 has been marked as a duplicate of this bug. ***
Comment 5 Matthew Barnes 2008-08-19 14:11:55 UTC
Created attachment 116964 [details] [review]
Proposed patch for Evolution

Introduce mail_session_shutdown(), which calls camel_shutdown().
Comment 6 timeless 2008-08-19 14:46:21 UTC
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).
Comment 7 Matthew Barnes 2008-08-19 14:55:58 UTC
So better to just remove the PR_Cleanup() call entirely then?
Comment 8 Lucian Langa 2008-08-19 14:57:50 UTC
+1
Comment 9 timeless 2008-08-19 15:33:01 UTC
yes please
Comment 10 Matthew Barnes 2008-08-19 15:52:53 UTC
Consider it removed.  No real need to post a revised patch.
Comment 11 Jeffrey Stedfast 2008-08-19 20:53:46 UTC
changes are ok with me
Comment 12 Srinivasa Ragavan 2008-08-20 03:33:31 UTC
Commit to trunk
Comment 13 Matthew Barnes 2008-08-21 02:25:26 UTC
Committed to trunk:

EDS: revision 6411
Evo: revision 36029