Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Invalid sys.stdin in interactive mode => loop forever. #55939

Closed
ysjray mannequin opened this issue Mar 31, 2011 · 2 comments
Closed

Setting Invalid sys.stdin in interactive mode => loop forever. #55939

ysjray mannequin opened this issue Mar 31, 2011 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ysjray
Copy link
Mannequin

ysjray mannequin commented Mar 31, 2011

BPO 11730
Nosy @vstinner

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-04-02.08:28:53.523>
created_at = <Date 2011-03-31.15:17:18.470>
labels = ['interpreter-core', 'type-crash']
title = 'Setting Invalid sys.stdin in interactive mode =>  loop forever.'
updated_at = <Date 2011-04-02.08:28:53.522>
user = 'https://bugs.python.org/ysjray'

bugs.python.org fields:

activity = <Date 2011-04-02.08:28:53.522>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2011-04-02.08:28:53.523>
closer = 'vstinner'
components = ['Interpreter Core']
creation = <Date 2011-03-31.15:17:18.470>
creator = 'ysj.ray'
dependencies = []
files = []
hgrepos = []
issue_num = 11730
keywords = []
message_count = 2.0
messages = ['132678', '132789']
nosy_count = 2.0
nosy_names = ['vstinner', 'ysj.ray']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue11730'
versions = ['Python 3.1', 'Python 3.2', 'Python 3.3']

@ysjray
Copy link
Mannequin Author

ysjray mannequin commented Mar 31, 2011

Setting sys.stdin to an invalid input stream under interactive mode causes interpreter run loop forever:

Python 3.3a0 (default:22ae2b002865+, Mar 30 2011, 21:17:03) 
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
[57804 refs]
>>> sys.stdin = None
[57809 refs]
[57809 refs]
[57809 refs]
[57809 refs]
[57809 refs]
......

Not only setting to None but also to any other invalid input stream could cause this. It's because in the beginning of PyRun_InteractiveOneFlags(), in order to get stdin encoding, the code tries to get sys.stdin and check if it's valid(not NULL, not None, has "encoding" attribute), if not, return -1 directly, then the loop in PyRun_InteractLoopFlags() continues and does the same thing. I think this should be fixed by using the Py_FileSystemDefaultEncoding instead when sys.stdin is invalid.

@ysjray ysjray mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Mar 31, 2011
@terryjreedy terryjreedy changed the title Setting sys.stdin to an invalid input stream causes interpreter run loop forever. Setting Invalid sys.stdin in interactive mode => loop forever. Apr 2, 2011
@vstinner
Copy link
Member

vstinner commented Apr 2, 2011

I think that it is a duplicate of bpo-8070.

@vstinner vstinner closed this as completed Apr 2, 2011
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

1 participant