The Problem: - you embed Python in some app - the app dynamically loads libexpat of version X - the embedded Python imports pyexpat (which was built against libexpat version X+n) --> pyexpat gets the expat symbols from the already loaded and *older* libexpat: crash (Specifically the crash we observed was in getting an old XML_ErrorString (from xmlparse.c) and then calling it with newer values in the XML_Error enum: // pyexpat.c, line 1970 ... // Added in Expat 1.95.7. MYCONST(XML_ERROR_UNBOUND_PREFIX); ... The Solution: Prefix all a exported symbols with "PyExpat_". This is similar to what Mozilla does for some common libs: http://lxr.mozilla.org/seamonkey/source/modules/libimg/png/mozpngconf.h#115 I'll attach the gdb backtrace that we were getting and a patch.
Logged In: YES user_id=33168 This seems to be a duplicate of bug #1075984. I like this patch better, but perhaps both patches (the one here and the other bug report) should be implemented? I think Martin helps maintain pyexpat. Maybe he has some ideas about either or both of these bugs/patches. Martin, do you think these are safe to apply? I can apply the patch(es) if you think it's safe. Trent, is this patch sufficient to meet your embedding needs so that nothing else needs to be done? I do not think this patch can be applied to 2.4.
Logged In: YES user_id=34892 > This seems to be a duplicate of bug #1075984. You are right. > Trent, is this patch sufficient to meet your embedding > needs so that nothing else needs to be done? Yes. > I do not think this patch can be applied to 2.4. That's fine. Getting this into Python >=2.5 would be good enough. Martin, Have you had a chance to review this?
Logged In: YES user_id=34892 Attempted summary to get this patch into Python 2.5: As Neal points out this is a duplicate of <http://python.org/sf/1075984>. The patch on *that* bug fixes the specific issue, but does not solve the general problem (as 'mwh' pointed out in the comments there). I think we should 1. apply this patch 2. then perhaps update our expat version (see http://python.org/sf/1433435, http://mail.python.org/pipermail/python-dev/2006-March/062287.html), 3. then update Modules/expat/pyexpatns.h (that this patch adds) for any new symbols in the new version of Expat. Neal, Martin, Michael, what do you think?
Logged In: YES user_id=34892 As well, *possibly* the same should be done for Python's bz2.so, although the only relevant exported symbol is Util_UnivNewlineRead nm bz2.so \ | grep -v " [a-zBUA] " \
Logged In: YES user_id=34892 Sending Modules/expat/expat_external.h Adding Modules/expat/pyexpatns.h Transmitting file data .. Committed revision 47034. I upgraded Python's expat to 2.0.0 immediately before and checked that no new symbols where added (i.e. no new #define's necessary for the patch).