New issue 2005: RPython OSError if you os.close() the wrong fd https://bitbucket.org/pypy/pypy/issue/2005/rpython-oserror-if-you-osclose-the-wrong
Antonio Cuni: Suppose to have the following bar.py and foo.py ``` #!python # bar.py import foo # foo.py import os os.close(3) # fd 3 points to foo.py ``` On CPython, it works fine; on PyPy, it crashes: ``` $ pypy bar.py RPython traceback: File "pypy_goal_targetpypystandalone.c", line 2206, in entry_point File "pypy_interpreter_pyframe.c", line 3185, in PyFrame_execute_frame File "rpython_jit_metainterp_warmspot.c", line 1858, in ll_portal_runner__Unsigned_Bool_pypy_interpreter File "pypy_module_pypyjit_interp_jit.c", line 289, in portal_5 File "pypy_interpreter_pyopcode.c", line 3468, in handle_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 7012, in dispatch_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 31276, in call_function__AccessDirect_None File "pypy_interpreter_pyframe.c", line 3185, in PyFrame_execute_frame File "rpython_jit_metainterp_warmspot.c", line 1858, in ll_portal_runner__Unsigned_Bool_pypy_interpreter File "pypy_module_pypyjit_interp_jit.c", line 289, in portal_5 File "pypy_interpreter_pyopcode.c", line 3468, in handle_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 7050, in dispatch_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 31276, in call_function__AccessDirect_None File "pypy_interpreter_pyframe.c", line 3185, in PyFrame_execute_frame File "rpython_jit_metainterp_warmspot.c", line 1858, in ll_portal_runner__Unsigned_Bool_pypy_interpreter File "pypy_module_pypyjit_interp_jit.c", line 289, in portal_5 File "pypy_interpreter_pyopcode.c", line 3468, in handle_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 7099, in dispatch_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 31276, in call_function__AccessDirect_None File "pypy_interpreter_pyframe.c", line 3185, in PyFrame_execute_frame File "rpython_jit_metainterp_warmspot.c", line 1858, in ll_portal_runner__Unsigned_Bool_pypy_interpreter File "pypy_module_pypyjit_interp_jit.c", line 289, in portal_5 File "pypy_interpreter_pyopcode.c", line 3468, in handle_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 7995, in dispatch_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 21370, in EXEC_STMT__AccessDirect_None File "pypy_interpreter_pyframe.c", line 3185, in PyFrame_execute_frame File "rpython_jit_metainterp_warmspot.c", line 1858, in ll_portal_runner__Unsigned_Bool_pypy_interpreter File "pypy_module_pypyjit_interp_jit.c", line 289, in portal_5 File "pypy_interpreter_pyopcode.c", line 3468, in handle_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 8067, in dispatch_bytecode__AccessDirect_None File "pypy_interpreter_pyopcode.c", line 25276, in IMPORT_NAME__AccessDirect_None File "pypy_interpreter_gateway.c", line 477, in BuiltinCode_funcrun_obj File "pypy_interpreter_gateway.c", line 2582, in BuiltinCode_handle_exception Fatal RPython error: OSError Aborted ``` This is probably caused by this code in module/imp/importing.py, inside load_part: ``` #!python try: if find_info: w_mod = load_module(space, w_modulename, find_info) [cut] finally: if find_info: stream = find_info.stream if stream: stream.close() ``` The stream.close() in the finally fails (because the fd has already been closed), but it's not caugth by anyone, and thus crashes the interpreter. Note that importing.py is full of stream.close() all around the place, so we probably need to think of a general solution for the problem. _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue