This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: lzma segfault when __init__ with non-existent file after executing the constructor (Python 2.7)
Type: crash Stage:
Components: Extension Modules Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: nadeem.vawda, vajrasky, vstinner
Priority: normal Keywords:

Created on 2013-12-04 16:33 by vajrasky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg205229 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-12-04 16:33
[sky@localhost cutecat]$ cat /tmp/lzma_segfault.py 
import lzma
file = lzma.LZMAFile("/tmp/file.lzma", "w")
file.write(b"xxxx")
file.close()
with lzma.LZMAFile("/tmp/file.lzma", "w") as f:
    f.__init__("non-existent")
[sky@localhost cutecat]$ python /tmp/lzma_segfault.py 
Segmentation fault (core dumped)

See also issue19878.

I'll provide the patch tomorrow.
msg205232 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2013-12-04 18:42
To clarify, which version(s) does this affect? I have not been able to
reproduce against 3.4, and 2.7 does not included the lzma module in the
first place.
msg205267 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-12-05 00:31
Wait, you're right. I have not been able to reproduce this under Python downloaded from Python.org.

[sky@localhost cpython2.7]$ ./python
Python 2.7.6+ (2.7:ae9fb85ab4e0, Dec  5 2013, 08:24:11) 
[GCC 4.7.2 20121109 (Red Hat 4.7.2-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lzma
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named lzma
[40709 refs]

The python is from Fedora itself. Maybe I did some funky stuff in my Fedora installation. Let me check this first and report to you later.

[sky@localhost cpython2.7]$ python
Python 2.7.3 (default, Aug  9 2012, 17:23:57) 
[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lzma
>>> lzma
<module 'lzma' from '/usr/lib64/python2.7/site-packages/lzma.so'>
msg207376 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-05 14:05
Okay, sorry guys. The python 2.7 lzma binding is Fedora specific one. I already submitted bug there: https://bugzilla.redhat.com/show_bug.cgi?id=1048581
History
Date User Action Args
2022-04-11 14:57:54adminsetgithub: 64084
2014-01-05 14:05:47vajraskysetstatus: open -> closed
2014-01-05 14:05:16vajraskysetstatus: pending -> open
resolution: not a bug
messages: + msg207376
2013-12-05 00:31:23vajraskysetstatus: open -> pending

messages: + msg205267
2013-12-04 18:42:51nadeem.vawdasetmessages: + msg205232
2013-12-04 17:05:43vstinnersetnosy: + vstinner
2013-12-04 16:48:37vajraskysettitle: lzma.LZMAFile.__init__() segfault when __init__ with non-existent file after executing the constructor -> lzma segfault when __init__ with non-existent file after executing the constructor (Python 2.7)
2013-12-04 16:33:46vajraskycreate