[New-bugs-announce] [issue35969] Interpreter crashes with "can't initialize init_sys_streams" when abc fails to import

Paul Ganssle report at bugs.python.org
Mon Feb 11 13:15:34 EST 2019


New submission from Paul Ganssle <p.ganssle at gmail.com>:

Just noticed this (tested on Python 3.7 and 3.8):

    mkdir /tmp/demo
    cd /tmp/demo
    cat << EOF > abc.py
    raise Exception("Hi")
    EOF
    PYTHONPATH=: python -c ""


This will crash the interpreter with:

    Fatal Python error: init_sys_streams: can't initialize sys standard 
streams
    Traceback (most recent call last):
      File ".../lib/python3.7/io.py", line 52, in <module>
      File "/tmp/demo/abc.py", line 1, in <module>
    Exception: Hi
    Aborted (core dumped)


It seems that the problem is that the io module imports the abc module, which raises an exception, so io fails to load. Evidently the io module is necessary to load the interpreter, so the interpreter crashes.

Here's the backtrace for 3.7.2 on Arch Linux:

(gdb) bt
#0  0x00007f234b3f0d7f in raise () from /usr/lib/libc.so.6
#1  0x00007f234b3db672 in abort () from /usr/lib/libc.so.6
#2  0x00007f234b7db490 in fatal_error (prefix=prefix at entry=0x7f234b9d5fe0 <__func__.16645> "init_sys_streams", 
    msg=msg at entry=0x7f234ba01f60 "can't initialize sys standard streams", status=status at entry=-1)
    at Python/pylifecycle.c:2179
#3  0x00007f234b8460cb in _Py_FatalInitError (err=...) at Python/pylifecycle.c:2198
#4  0x00007f234b8495a9 in pymain_init (pymain=0x7fff971cca70) at Modules/main.c:3019
#5  0x0000555dfa560050 in ?? ()
#6  0x00007fff971ccbc0 in ?? ()
#7  0x0000000000000000 in ?? ()


I'm not sure if anything can or should be done about this. It's very fair for the interpreter to fail to start, though I would guess that it should do that without dumping a core.

----------
messages: 335244
nosy: p-ganssle
priority: normal
severity: normal
status: open
title: Interpreter crashes with "can't initialize init_sys_streams" when abc fails to import
type: crash
versions: Python 2.7, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35969>
_______________________________________


More information about the New-bugs-announce mailing list