Skip to content

profiling with xml parsing asserts #36330

Closed

Description

@ainsinga
mannequin
BPO 534864
Nosy @gvanrossum, @tim-one, @loewis
Files
  • profilexmlcrash.txt
  • traceback.txt: A failing run under CVS on Windows
  • expat.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/loewis'
    closed_at = <Date 2002-08-04.08:27:28.000>
    created_at = <Date 2002-03-25.21:15:27.000>
    labels = ['library']
    title = 'profiling with xml parsing asserts'
    updated_at = <Date 2002-08-04.08:27:28.000>
    user = 'https://bugs.python.org/ainsinga'

    bugs.python.org fields:

    activity = <Date 2002-08-04.08:27:28.000>
    actor = 'loewis'
    assignee = 'loewis'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2002-03-25.21:15:27.000>
    creator = 'ainsinga'
    dependencies = []
    files = ['392', '393', '394']
    hgrepos = []
    issue_num = 534864
    keywords = []
    message_count = 15.0
    messages = ['9974', '9975', '9976', '9977', '9978', '9979', '9980', '9981', '9982', '9983', '9984', '9985', '9986', '9987', '9988']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'tim.peters', 'loewis', 'ainsinga', 'andrewl']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue534864'
    versions = ['Python 2.2']

    Activity

    1. ainsinga commented on Mar 25, 2002

      ainsingamannequin
      MannequinAuthor

      I'm getting a 'bad call' assertion error when using the
      profiler when parsing XML. (It works ok without the
      profiler, and if I don't call SAXparser.parse it
      doesn't happen.)

      Python 2.2 (#1, Dec 23 2001, 09:30:32)
      [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on
      linux2
      Type "help", "copyright", "credits" or "license" for
      more information.
      >>> import t4crash
      start document
      end document
      >>> import profile
      >>> t4crash.test()
      start document
      end document
      >>> profile.run('t4crash.test()')
      start document
      Traceback (most recent call last):
        File "<stdin>", line 1, in ?
        File "/usr/lib/python2.2/profile.py", line 71, in run
          prof = prof.run(statement)
        File "/usr/lib/python2.2/profile.py", line 404, in
      run
          return self.runctx(cmd, dict, dict)
        File "/usr/lib/python2.2/profile.py", line 410, in
      runctx
          exec cmd in globals, locals
        File "<string>", line 1, in ?
        File "t4crash.py", line 46, in test
          main(files)
        File "t4crash.py", line 39, in main
          SAXparser.parse(fileName)
        File
      "/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py",
      line 53, in parse
        File
      "/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/xmlreader.py",
      line
      123, in parse  File
      "/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py",
      line 106,
      in feed
        File
      "/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py",
      line 179, in start_element
        File "/usr/lib/python2.2/profile.py", line 214, in
      trace_dispatch_i
          if self.dispatch[event](self, frame,t):
        File "/usr/lib/python2.2/profile.py", line 260, in
      trace_dispatch_call
          assert rframe.f_back is frame.f_back, ("Bad call",
      rfn,
      AssertionError: ('Bad call',
      ('/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py',
      95,
      'feed'), <frame object at 0x81d5454>, <frame object at
      0x81c82e4>, <frame object
      at 0x81d50b4>, <frame object at 0x81d5284>)
      >>>
      [ainsinga@ainsinga index_xml]$ cat t4crash.py
      #!/usr/bin/env python2

      # t4crash.py by Aron K. Insinga ([email protected])
      25-Mar-2002

      import xml.sax
      import sys
      import string
      import re
      
      
      class ContentHandler(xml.sax.ContentHandler):
          """ Handle callbacks from the SAX XML parser. """
      
          def __init__(selfy):
              pass
      
          def setDocumentLocator(self, locator):
              pass
      
          def startDocument(self):
              print 'start document'
      
          def endDocument(self):
              print 'end document'
      
          def startElement(self, name, attrs):
              pass
      
          def endElement(self, name):
              pass
      
      
      def main(files):
          SAXparser = xml.sax.make_parser()
          chand = ContentHandler()
          SAXparser.setContentHandler(chand)
          try:
              for fileName in files:
                  SAXparser.parse(fileName)
          except xml.sax.SAXParseException:
              sys.stderr.write("%s; processing aborted\n" %
      (xml.sax.SAXParseException))
              sys.exit(1)
      
      def test():
          files = ['doc0.xml']
          main(files)
      
      test()
      [ainsinga@ainsinga index_xml]$ cat doc0.xml
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <html>
        <head>
          <title>Gettysburg Address</title>
        </head>
        <body>
          <p>
            Four score and seven years ago...<br/>
          </p>
        </body>
        <info>
          <author>
           
      <lastname>Lincoln</lastname><firstname>Abraham</firstname>
          </author>
          <date>
            <month>11</month><day>19</day><year>1863</year>
          </date>
          <editor /><!-- editor name="aki"/ -->
          <editor/>
        </info>
      </html>
      [ainsinga@ainsinga index_xml]$ which python
      /usr/bin/python
      [ainsinga@ainsinga index_xml]$ set | grep PATH
      LD_LIBRARY_PATH=/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:
      PATH=$'/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:.:/home/ainsinga/bin:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:~/staroffice6.0:/home/ainsinga/mozilla:~/staroffice6.0:/home/ainsinga/mozilla:~/staroffice6.0:/home/ainsinga/mozilla:~/staroffice6.0:/home/ainsinga/mozilla:~/
      staroffice6.0:/home/ainsinga/mozilla'
      [ainsinga@ainsinga index_xml]$ set | grep -i py
      [ainsinga@ainsinga index_xml]$uname -a
      Linux ainsinga 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001
      i686 unknown
      [ainsinga@ainsinga index_xml]$
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Mar 25, 2002
    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Mar 25, 2002
    4. ainsinga commented on Mar 25, 2002

      ainsingamannequin
      MannequinAuthor

      Logged In: YES
      user_id=496408

      attached is the sample program (which ought to have
      indenting preserved!)

    5. tim-one commented on Mar 25, 2002

      @tim-one
      Member

      Logged In: YES
      user_id=31435

      Assigned to Fred.

    6. loewis commented on Mar 27, 2002

      loewismannequin
      Mannequin

      Logged In: YES
      user_id=21627

      I can't reproduce the crash, with 2.3a0.

    7. loewis commented on Jul 1, 2002

      loewismannequin
      Mannequin

      Logged In: YES
      user_id=21627

      I can't reproduce it with the Python 2.2 that ships with
      SuSE 8.0, either.

    8. tim-one commented on Jul 1, 2002

      @tim-one
      Member

      Logged In: YES
      user_id=31435

      I reproduced this with current CVS Python on Windows;
      see attached traceback.txt, which shows a screen dump of
      the offending <wink> interactive session.

    9. andrewl commented on Jul 1, 2002

      andrewlmannequin
      Mannequin

      Logged In: YES
      user_id=28733

      There is another filing on this problem at:

      http://mail.python.org/pipermail/xml-sig/2002-April/007632.html

      Also, I reproduced this on another FreeBSD box today as
      well.

      andrewl@taz:andrewl$ python
      Python 2.2.1 (#1, May 27 2002, 16:42:22)
      [GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4

      -a

    10. andrewl commented on Jul 2, 2002

      andrewlmannequin
      Mannequin

      Logged In: YES
      user_id=28733

      Here is a session log for a much more self-contained
      regression file (xmltest.py):

      andrewl@taz:andrewl$ python
      Python 2.2.1 (#1, May 27 2002, 16:42:22) 
      [GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
      Type "help", "copyright", "credits" or "license" for more
      information.
      >>> import profile
      >>> import xmltest
      >>> profile.run('xmltest.main()')
      Traceback (most recent call last):
        File "<stdin>", line 1, in ?
        File "/usr/local/lib/python2.2/profile.py", line 71, in
      run
          prof = prof.run(statement)
        File "/usr/local/lib/python2.2/profile.py", line 404, in
      run
          return self.runctx(cmd, dict, dict)
        File "/usr/local/lib/python2.2/profile.py", line 410, in
      runctx
          exec cmd in globals, locals
        File "<string>", line 1, in ?
        File "xmltest.py", line 24, in main
          xml.sax.parseString(testxml, chand)
        File "/usr/local/lib/python2.2/xml/sax/__init__.py", line
      49, in parseString
          parser.parse(inpsrc)
        File "/usr/local/lib/python2.2/xml/sax/expatreader.py",
      line 90, in parse
          xmlreader.IncrementalParser.parse(self, source)
        File "/usr/local/lib/python2.2/xml/sax/xmlreader.py", line
      123, in parse
          self.feed(buffer)
        File "/usr/local/lib/python2.2/xml/sax/expatreader.py",
      line 143, in feed
          self._parser.Parse(data, isFinal)
        File "/usr/local/lib/python2.2/xml/sax/expatreader.py",
      line 216, in start_element
          def start_element(self, name, attrs):
        File "/usr/local/lib/python2.2/profile.py", line 214, in
      trace_dispatch_i
          if self.dispatch[event](self, frame,t):
        File "/usr/local/lib/python2.2/profile.py", line 260, in
      trace_dispatch_call
          assert rframe.f_back is frame.f_back, ("Bad call", rfn,
      AssertionError: ('Bad call',
      ('/usr/local/lib/python2.2/xml/sax/expatreader.py', 132,
      'feed'), <frame object at 0x81a880c>, <frame object at
      0x81a840c>, <frame object at 0x81bb60c>, <frame object at
      0x81a8a0c>)
    11. andrewl commented on Jul 2, 2002

      andrewlmannequin
      Mannequin

      Logged In: YES
      user_id=28733

      The xmltest.py program follows since I appear to be too
      stupid to figure out how to attach a file to a bug report on
      SourceForge.

      -a

      #!/usr/bin/env python

      import xml.sax

      testxml = \
      """
      <html />
      """

      class ContentHandler(xml.sax.ContentHandler):
          """ Handle callbacks from the SAX XML parser. """
      
          def __init__(self):
              pass
      
          def startElement(self, name, attrs):
              print "start element"
      
          def endElement(self, name):
              print "end element"
      
      def main():
          chand = ContentHandler()
          xml.sax.parseString(testxml, chand)
      
      if __name__ == "__main__":
          main()
    12. loewis commented on Jul 2, 2002

      loewismannequin
      Mannequin

      Logged In: YES
      user_id=21627

      Attached is a patch that fixes the problem.

    13. andrewl commented on Aug 1, 2002

      andrewlmannequin
      Mannequin

      Logged In: YES
      user_id=28733

      I took a quick look in the browsable CVS repository, and the
      diff to expat.c doesn't seem to be committed. Is there
      something further that I need to do so that this bug can get
      closed?

      -a

    14. loewis commented on Aug 1, 2002

      loewismannequin
      Mannequin

      Logged In: YES
      user_id=21627

      Confirming that the patch solves the problem for you would help.

    15. gvanrossum commented on Aug 2, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      It solves the isolated test case submitted by Andrew P.
      Lentvorski to python-dev on July 1, so I propose to check
      this in.

    16. andrewl commented on Aug 2, 2002

      andrewlmannequin
      Mannequin

      Logged In: YES
      user_id=28733

      I didn't realize you were waiting for confirmation from me
      directly. Preliminary runs look like the problem is fixed.

      Please commit the patch and mark this bug as closed.

    17. loewis commented on Aug 4, 2002

      loewismannequin
      Mannequin

      Logged In: YES
      user_id=21627

      Committed as pyexpat.c 2.72 and 2.57.6.1.

    18. transferred this issue fromon Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibStandard Library Python modules in the Lib/ directory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions