classification
Title: expat symbols should be namespaced in pyexpat
Type: Stage:
Components: Extension Modules Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: tmick Nosy List: nnorwitz, tmick
Priority: normal Keywords:

Created on 2005-09-19 21:44 by tmick, last changed 2006-06-19 23:59 by tmick. This issue is now closed.

Files
File name Uploaded Description Edit
expat_crash_backtrace.txt tmick, 2005-09-19 21:45 GDB crash backtrace that we were getting
pyexpat_namespace_symbols.patch tmick, 2005-09-19 21:47 suggested patch to namespace expat symbols
Messages (6)
msg26323 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2005-09-19 21:44
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.
msg26324 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2005-09-30 06:01
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.
msg26325 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2006-01-24 23:34
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?
msg26326 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2006-03-18 23:58
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?
msg26327 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2006-03-19 00:25
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] " \
    | grep -v "_fini\|_init\|initbz2"

msg26328 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2006-06-19 23:59
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).
History
Date User Action Args
2005-09-19 21:44:01tmickcreate