Crashes when trying to read from STDIN
See original GitHub issueProblem Description
Always crashes when trying to read from STDIN.
Steps to reproduce the behavior:
- Create an empty file
empty
, i.e.touch empty
. tail -f ./empty | mitmproxy --rfile - -n
What happens:
$ tail -f ./empty | mitmproxy --rfile - -n
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/mitmproxy/master.py", line 86, in run_loop
loop()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 286, in run
self._run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 384, in _run
self.event_loop.run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 1484, in run
reraise(*exc_info)
File "/usr/local/lib/python3.7/dist-packages/urwid/compat.py", line 55, in reraise
value = tp()
TypeError: 'NoneType' object is not callable
mitmproxy has crashed!
Please lodge a bug report at:
https://github.com/mitmproxy/mitmproxy
$ tail -f ./empty | mitmproxy --rfile empty -n
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/mitmproxy/master.py", line 86, in run_loop
loop()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 286, in run
self._run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 384, in _run
self.event_loop.run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 1484, in run
reraise(*exc_info)
File "/usr/local/lib/python3.7/dist-packages/urwid/compat.py", line 58, in reraise
raise value
File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 404, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 436, in get_available_raw_input
codes = self._get_gpm_codes() + self._get_keyboard_codes()
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 510, in _get_keyboard_codes
code = self._getch_nodelay()
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 644, in _getch_nodelay
return self._getch(0)
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 554, in _getch
return ord(os.read(self._term_input_file.fileno(), 1))
TypeError: ord() expected a character, but string of length 0 found
mitmproxy has crashed!
Please lodge a bug report at:
https://github.com/mitmproxy/mitmproxy
Important: If you load the file directly, it always works!
Also, with a real-life file, the errors vary. It always takes a long time showing nothing and then crashes:
$ tail -f ./mitmproxy-flow.cap | mitmproxy --rfile - -n
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/mitmproxy/master.py", line 86, in run_loop
loop()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 286, in run
self._run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 384, in _run
self.event_loop.run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 1484, in run
reraise(*exc_info)
File "/usr/local/lib/python3.7/dist-packages/urwid/compat.py", line 55, in reraise
value = tp()
TypeError: 'NoneType' object is not callable
mitmproxy has crashed!
Please lodge a bug report at:
https://github.com/mitmproxy/mitmproxy
sys:1: RuntimeWarning: coroutine 'Master._shutdown' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
$ tail -f ./mitmproxy-flow.cap | mitmproxy --rfile - -n
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/mitmproxy/master.py", line 86, in run_loop
loop()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 286, in run
self._run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 384, in _run
self.event_loop.run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 1484, in run
reraise(*exc_info)
File "/usr/local/lib/python3.7/dist-packages/urwid/compat.py", line 55, in reraise
value = tp()
TypeError: 'NoneType' object is not callable
mitmproxy has crashed!
Please lodge a bug report at:
https://github.com/mitmproxy/mitmproxy
sys:1: RuntimeWarning: coroutine 'Master._shutdown' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
I’ve also tried to not write into the file simoultaneously, and avoid using the -f
command with tail. Nothing prevents the crashes.
$ tail ./empty | mitmproxy --rfile - -n
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/mitmproxy/master.py", line 86, in run_loop
loop()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 286, in run
self._run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 384, in _run
self.event_loop.run()
File "/usr/local/lib/python3.7/dist-packages/urwid/main_loop.py", line 1484, in run
reraise(*exc_info)
File "/usr/local/lib/python3.7/dist-packages/urwid/compat.py", line 58, in reraise
raise value
File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 404, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 436, in get_available_raw_input
codes = self._get_gpm_codes() + self._get_keyboard_codes()
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 510, in _get_keyboard_codes
code = self._getch_nodelay()
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 644, in _getch_nodelay
return self._getch(0)
File "/usr/local/lib/python3.7/dist-packages/urwid/raw_display.py", line 554, in _getch
return ord(os.read(self._term_input_file.fileno(), 1))
TypeError: ord() expected a character, but string of length 0 found
mitmproxy has crashed!
Please lodge a bug report at:
https://github.com/mitmproxy/mitmproxy
Important: When loading the file directly (not from STDIN), it works without any problem, even for an empty file!
Previous crashes/information: https://github.com/mitmproxy/mitmproxy/issues/1002#issuecomment-665169972
System Information
$ mitmproxy --version
Mitmproxy: 5.2
Python: 3.7.3
OpenSSL: OpenSSL 1.1.1d 10 Sep 2019
Platform: Linux-5.4.51-v7l+-armv7l-with-debian-10.4
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Python crashing at `input(...)` after reading from STDIN
You have already read from stdin until end of file, but you could read from the terminal device: import sys print(len(sys.stdin.read())) ...
Read more >_setmode _O_U8TEXT on _fileno(stdin) crashes program ...
_setmode _O_U8TEXT on _fileno(stdin) crashes program when try to read form std::cin.. LOLuan Vitor Simião Oliveira.
Read more >Calibre DRC crashes: Failure to read input file stdin.gds at ...
I want have a class-based architecture in my design, ... DRC tool (Calibre crashes with the message “Failure to read input file stdin.gds...
Read more >AFL Quick Start Guide — AFL 2.53b documentation
The program must crash properly when a fault is encountered. Watch out for custom SIGSEGV or ... If the program reads from stdin,...
Read more >Dying, fast and slow: out-of-memory crashes in Python
When some code tries to read or write to these chunks they will get loaded back into RAM. Now, your disk is much...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Done: https://github.com/urwid/urwid/issues/423
pipx works just as well, it’s just a more user-friendly wrapper around virtualenvs. Please feel free to report this upstream, urwid shouldn’t crash if you provide a file as stdin. That being said, you don’t want to pipe into
mitmproxy
, that doesn’t work well because you need stdin for keyboard input.As a general comment, you have posted a serious double-digit number of comments over the last two days on our issue tracker. We appreciate feedback, but can’t cope with that. Please tune down your volume considerably and try to be more helpful than demanding. Thanks.