[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[xml] crash with SAXParseFile



- I downloaded libxml2-2.6.3.tar.gz today December 10th.
- built it on Mac OS X 10.3.1 with:
  ./configure --with-python=/Library/Frameworks/Python.framework/Versions/2.3

- when I run the python code attached in file t21.py, I get a bus error.

I tracked it down to an inconsistency between usage of ctxt->_private and
ctxt->userData. The xmlSAXParseFileWithData function in parser.c only sets
ctxt->_private, yet further down the xmlParseDocument function calls
ctxt->sax->startDocument(ctxt->userData), which ultimately causes the
pythonStartDocument function in python/libxml.c to call PyObject_HasAttrString
with a bogus handler argument and the process to crash with a bus error.

By inserting at line 11535 in parser.c, ctxt->userData = data, the crash is
worked around and SAX parsing from python seems to work again.

Andi..
import libxml2

class ContentHandler(object):
    
    def startDocument(self):
        pass

    def endDocument(self):
        pass

    def startElement(self, tag, attrs):
        print 'startElement', tag, attrs

    def endElement(self, tag):
        pass
    
    def characters(self, data):
        pass
    
    def warning(self, msg):
        pass

    def error(self, msg):
        pass

    def fatalError(self, msg):
        pass



handler = ContentHandler()
libxml2.SAXParseFile(handler, "cineguide.pack", 0)
<?xml version="1.0"?>

<pack name="CineGuide" cwd="cineguide">

  <item path="//Schema">
    <item file="CineGuide.domain" cwd="schema">
      <item file="Types.namespace" cwd="types">
        <item files="*.type" />
      </item>
      <item file="Attributes.namespace" cwd="attributes">
        <item files="*.attr" />
      </item>
      <item file="Kinds.namespace" cwd="kinds">
        <item files="*.kind" />
      </item>
    </item>
  </item>
  
  <item file="CineGuide.root">
    <item files="*.director" />
    <item files="*.actor" />
    <item files="khepburn.movies" />
  </item>

</pack>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]