New issue 3042: crash when reading non-blocking subprocess output
https://bitbucket.org/pypy/pypy/issues/3042/crash-when-reading-non-blocking-subprocess

Jacob Lifshay:

Output:

```
RPython traceback:
  File "pypy_interpreter.c", line 37926, in BuiltinCode_funcrun_obj
  File "pypy_module__io_1.c", line 11207, in W_BufferedReader_readline_w
  File "implement_2.c", line 32105, in dispatcher_70
  File "pypy_module__io.c", line 15998, in W_BufferedReader__raw_read
Traceback (most recent call last):
  File "pypy_bug.py", line 10, in <module>
    s = p.stdout.readline()
SystemError: unexpected internal exception (please report a bug): 
<BlockingIOError object at 0x7f9481569f00>; internal traceback was dumped to 
stderr
```

Versions:  
Python 3.6.1 \(7a2e437acfce, Mar 21 2019, 13:39:41\)  
\[PyPy 7.2.0-beta0 with GCC 6.2.0 20160901\]  
Ubuntu 18.04 x86\_64

reproducable using:

```python
import subprocess
import fcntl
import os
from select import select

p = subprocess.Popen(["/bin/bash", "-c", "printf ''"], 
stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=None)
fl = fcntl.fcntl(p.stdout, fcntl.F_GETFL)
fcntl.fcntl(p.stdout, fcntl.F_SETFL, fl | os.O_NONBLOCK)
while True:
    s = p.stdout.readline()
    print(s)
    if len(s) == 0:
        if p.poll() is not None:
            break
        try:
            select([p.stdout], [], [], 1.0)
        except InterruptedError:
            pass
```


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to