Crash on double list(lxml.etree.iterparse(f))

Bug #1833050 reported by Kurakin Alexander
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Invalid
Undecided
Unassigned

Bug Description

lxml 4.3.3 (Python 3.7, Anaconda, Linux 64bit)

test.py:

import lxml
import lxml.etree

with open('test.xml', 'rb') as f:
    list(
        lxml.etree.iterparse(f)
    )

    # Traceback (most recent call last):
    # File "test.py", line 18, in <module>
    # lxml.etree.iterparse(f)
    # File "src/lxml/iterparse.pxi", line 209, in lxml.etree.iterparse.__next__
    # File "src/lxml/iterparse.pxi", line 194, in lxml.etree.iterparse.__next__
    # File "src/lxml/iterparse.pxi", line 225, in lxml.etree.iterparse._read_more_events
    # File "src/lxml/parser.pxi", line 1380, in lxml.etree._FeedParser.close
    # Segmentation fault
    list(
        lxml.etree.iterparse(f)
    )

test.xml:

<?xml version="1.0" encoding="UTF-8"?>
<root></root>

(or any else)

Revision history for this message
scoder (scoder) wrote :

Cannot reproduce a crash. What I see is an exception on the second call, because it's reading from an "empty" file and finds no XML in it.

Changed in lxml:
status: New → Invalid
Revision history for this message
Kurakin Alexander (kuraga333) wrote :

Ok. Can you read output, please, and say if it looks like a Python bug? https://gist.github.com/kuraga/2633915c6689f7a9484bbd6d605043e1 . (BTW, lxml-4.4.1) Thanks.

Revision history for this message
Kurakin Alexander (kuraga333) wrote :

BTW, in Gentoo's Python 3.6 I have the same.

But in Python 2.7 I don't have segfault:

    Traceback (most recent call last):
      File "test.py", line 19, in <module>
        lxml.etree.iterparse(f)
      File "src/lxml/iterparse.pxi", line 209, in lxml.etree.iterparse.__next__
      File "/home/sasha/_lxml-bug/test.xml", line 0
    lxml.etree.XMLSyntaxError: no element found

Did you try Python 3 or 2?

Revision history for this message
Kurakin Alexander (kuraga333) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.