[missing-sync-palmos-dev-talk] Crashes at exit under Palm Desktop
on Panther
Stuart A. Malone
samalone at llamagraphics.com
Wed May 31 13:18:02 PDT 2006
After a couple days of tough debugging, Catherine and I have another
tip to share with developers who are writing conduits under Xcode
that will be running under Palm Desktop on Panther.
The symptom is that both the HotSync Manager and the Conduit Manager
crash on exit on Palm Desktop under Panther. The stack trace is very
short, only a few frames, and does not point to the conduit code. In
our case it was pointing to OpaqueICInstance. The conduit runs fine,
but the parent application crashes on exit. Removing the conduit
from the Conduits folder eliminates the crash. Tiger, Missing Sync,
and Intel Macs do not seem to be affected by this problem.
The crash only occurs if the conduit calls atexit(), so many conduits
will not be affected. However, any C++ code that contains static
destructors implicitly calls atexit(), so this does affect any
conduits written in C++ that have globally or statically allocated
objects with destructors. The problem seems to be that the
destructors for the conduit are being registered with the main
application, and when the main application quits it tries to call the
(no longer loaded) destructors in the conduit.
This problem is more likely to affect developers porting conduits
from CodeWarrior, since CodeWarrior used a different technique for
calling static destructors that worked properly in conduits.
If you suspect that your conduit may be suffering from this problem,
it is simple enough to check:
nm -u /path/to/Conduit.plugin/Contents/MacOS/Conduit | fgrep atexit
If you get a line containing "U ___cxa_atexit", then your conduit
will probably crash under Palm Desktop on Panther.
Of course, one solution is to rewrite the conduit to not call atexit
() or use any static C++ objects. If this is not practical, there is
some code available from the folks at OmniGroup that redefines atexit
() so that it stores termination handlers for the conduit separately
from the main application. I have not tried this code yet, but I
will be soon. I have some concerns that their code seems to be
relying on a static destructor to trigger the cleanup, which seems a
bit too self-referential to actually work, but perhaps there is
something subtle going on that I have missed. In any case, it seems
that something similar to their solution should work:
<http://lists.apple.com/archives/Projectbuilder-users/2003/Sep/
msg00158.html>
I'll let you know when we have tested their solution more
thoroughly. In the meantime, we'd love to hear from anyone else who
may have encountered this problem.
Best wishes,
--Stuart A. Malone
Llamagraphics, Inc.
Makers of Life Balance personal coaching software
http://www.llamagraphics.com/
More information about the missing-sync-palmos-dev-talk
mailing list