[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Antoine Pitrou added the comment: Seems fixed now. -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Antoine Pitrou added the comment: The bug still fails on a regular basis on the Windows buildbots: == FAIL: test_bug7732 (test.test_imp.ImportTests) -- Traceback (most recent call last): File E:\Data\buildslave\cpython\3.x.snakebite-win2k3r2sp2-x86\build\lib\test\test_imp.py, line 285, in test_bug7732 imp.find_module, support.TESTFN, [.]) AssertionError: ImportError not raised by find_module -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Roundup Robot added the comment: New changeset 4f7845be9e23 by Antoine Pitrou in branch 'default': Issue #7732: try to fix test_bug7732's flakiness on Windows by executing it in a fresh temporary directory. http://hg.python.org/cpython/rev/4f7845be9e23 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
STINNER Victor added the comment: The test just failed on x86 Windows Server 2003 [SB] 3.x: http://buildbot.python.org/all/builders/x86%20Windows%20Server%202003%20%5BSB%5D%203.x/builds/1077/steps/test/logs/stdio == FAIL: test_bug7732 (test.test_imp.ImportTests) -- Traceback (most recent call last): File E:\Data\buildslave\cpython\3.x.snakebite-win2k3r2sp2-x86\build\lib\test\test_imp.py, line 285, in test_bug7732 imp.find_module, support.TESTFN, [.]) AssertionError: ImportError not raised by find_module -- resolution: fixed - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Roundup Robot added the comment: New changeset bf882390713c by Brett Cannon in branch 'default': Issue #7732: Move an imp.find_module test from test_import to http://hg.python.org/cpython/rev/bf882390713c -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by STINNER Victor victor.stin...@haypocalc.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 555871844962 by Victor Stinner in branch '2.7': Issue #7732: Try to fix the a failing test on Windows http://hg.python.org/cpython/rev/555871844962 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Antoine Pitrou pit...@free.fr added the comment: Victor, can you fix the test failures on Windows and 2.7? Otherwise the commit should be reverted. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Antoine Pitrou pit...@free.fr added the comment: This broke the Windows buildbots in Python 2.7. -- assignee: - haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Barry A. Warsaw ba...@python.org added the comment: Note that Python 2.6 is also vulnerable to the crash. While we do not have an exploit, we did get a report on security@ which led to this bug. I could be convinced to allow the patch to 2.6 on grounds that if the crasher can be exploited, better to apply it now rather than wait. Certainly if it's easier to apply 2.6 and forward port, I'm fine with that. Victor's pyfile_fromfile_close.patch looks good to me and fixes the problem with no discernible ill effects. On IRC, he said he'll apply it to 2.7, 3.2, and 3.3. I will approve it for 2.6 if he wants to apply it there too. -- nosy: +barry versions: +Python 2.6, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Barry A. Warsaw ba...@python.org: -- versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 125887a41a6f by Victor Stinner in branch '3.2': Issue #7732: Don't open a directory as a file anymore while importing a http://hg.python.org/cpython/rev/125887a41a6f New changeset 8c6fea5794b2 by Victor Stinner in branch 'default': Merge 3.2: Issue #7732: Don't open a directory as a file anymore while http://hg.python.org/cpython/rev/8c6fea5794b2 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 0f5b64630fda by Victor Stinner in branch '2.7': Issue #7732: Fix a crash on importing a module if a directory has the same name http://hg.python.org/cpython/rev/0f5b64630fda -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
STINNER Victor victor.stin...@haypocalc.com added the comment: import_directory-py3k.patch: find_module_path_list() ignores silently directories matching requested filename pattern (like module_name + .py). I don't think that it is useful to emit a warning (or raise an error) here, the code checks for various file extensions, not only .pyc: .so, .pyd, ... -- Added file: http://bugs.python.org/file22415/import_directory-py3k.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
STINNER Victor victor.stin...@haypocalc.com added the comment: pyfile_fromfile_close.patch: patch based on issue7732_find_module_v2.diff, fixing this issue in Python 2.7 - PyFile_FromFile() closes the file on PyString_FromString() failure (note: unlikely failure) - call_find_module() doesn't close the file anymore, PyFile_FromFile() closes already the file on failure (e.g. if the path is a directory) - update PyFile_FromFile() doc to simplify that the file is closed on error -- Added file: http://bugs.python.org/file22416/pyfile_fromfile_close.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: +Python 3.3 -Python 2.6, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Florent Xicluna florent.xicl...@gmail.com added the comment: According to message http://bugs.python.org/issue7732#msg102702, someone should write a patch for 3.x too. -- assignee: flox - stage: patch review - needs patch versions: +Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Mark Lawrence breamore...@yahoo.co.uk added the comment: Quote from ncoghlan on msg102699 Florent's patch looks correct. Does anyone else wish to comment or can this be taken forward? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Florent Xicluna florent.xicl...@gmail.com added the comment: see also http://bugs.python.org/issue8352#msg102662 -- nosy: +doko, l0nwlf, ncoghlan, orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Nick Coghlan ncogh...@gmail.com added the comment: I can reproduce this locally. I believe it is relevant that a simple import crash (with crash.py as the directory) doesn't cause a problem - there must be something higher in the import machinery which avoids the issue. -- assignee: - ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Nick Coghlan ncogh...@gmail.com added the comment: Ah, OK - the problem is confined solely to the wrapper for the Python imp module function. The normal import machinery doesn't go through the wrapper and hence doesn't have the problem. The PyFile_FromFile logic is a little convoluted, but Florent's patch looks correct. Currently, if the dircheck call in fill_file_fields fails, the function returns NULL, but leaves the file object populated (included its f_fp field). The Py_DECREF call then implicitly closes the file, resulting in a double close when call_find_module does the same thing manually. One other thing that is a little dubious in this code is the lack of error checking on the conversion of mode to a string object in fill_file_fields. That's fine for file_init (where mode came from a Python string object in the first place), but not valid for PyFile_FromFile (where mode is passed in as a char * instance). -- assignee: ncoghlan - flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Nick Coghlan ncogh...@gmail.com added the comment: An interesting part of this story is *why* it doesn't crash in Py3k (despite explicitly closing the file descriptor in the same way as 2.x closes the C file pointer). The reason is that PyFile_FromFd (the closest Py3k equivalent to PyFile_FromFile) will sometimes leave the file descriptor open, even if closefd is True. Specifically, this will happen if the raw file IO object fails to be created. Any subsequent failure while opening the file (e.g. while creating the line buffering or text wrapper) will trigger the same double close bug as occurs in 2.x. io_open needs to be fixed so this behaviour is consistent: if creation of the raw file IO object fails and closefd is True, io_open should close the file descriptor so that the behaviour on error is consistent. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Florent Xicluna florent.xicl...@gmail.com: -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Florent Xicluna la...@yahoo.fr: -- stage: needs patch - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: This is slightly incorrect: if PyFile_FromFile fails for another reason (PyString_FromString(name) runs out of memory), the fp is not closed and the caller is right to call fclose(). IMO PyFile_FromFile() should be changed to consistently leave the fp opened when NULL is returned. But then, many usages of this function are incorrect, e.g in posixmodule.c :-( -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file15937/issue7732_find_module.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Florent Xicluna la...@yahoo.fr added the comment: if PyFile_FromFile fails for another reason (PyString_FromString(name) runs out of memory), the fp is not closed and the caller is right to call fclose(). As far as I understand, the fp is never left open, when PyFile_FromFile returns NULL. So there's no reason to call fclose on it. However I found a reference leak in the case you describe (PyString_FromString(name) == NULL). It is fixed with this last update. -- Added file: http://bugs.python.org/file16029/issue7732_find_module_v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Trundle andy-pyt...@hammerhartes.de added the comment: Note that the fp gets set with `fill_file_fields()` and that is called after the error return of `PyString_FromString()`. Hence, the fp is left open if `PyString_FromString()` returns NULL. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Florent Xicluna la...@yahoo.fr added the comment: AFAICT, in this case, if PyString_FromString gives NULL, then (o_name == NULL) and the function returns without calling fill_file_fields. Hence, the fp is not opened. Do you suggest something else? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Trundle andy-pyt...@hammerhartes.de added the comment: `fill_file_fields()` does not open the fp, the caller of `PyFile_FromFile()` opens the fp. I don't have a better idea, that's why I don't have provided a patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
New submission from Trundle andy-pyt...@hammerhartes.de: Create a directory __init__.py and execute import imp imp.find_module('__init__', ['.']) to reproduce that issue. It will crash because Python tries to double-close a file pointer: `call_find_module` will call `PyFile_FromFile`, but `PyFile_FromFile` closes the file pointer if it's a directory (by decrefing the created file object) and ` call_find_module` then closes the already closed file. -- components: Library (Lib) messages: 98007 nosy: Trundle severity: normal status: open title: imp.find_module crashes Python if there exists a directory named __init__.py type: crash versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Florent Xicluna la...@yahoo.fr added the comment: Confirmed on trunk. ~ $ mkdir foo.py ~ $ ./python -c 'import imp;imp.find_module(foo, [.])' *** glibc detected *** ./python: double free or corruption (!prev): 0x024a7390 *** === Backtrace: = (...) -- nosy: +flox stage: - needs patch versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
R. David Murray rdmur...@bitdance.com added the comment: Confirmed that this does not affect py3k. -- nosy: +brett.cannon, r.david.murray priority: - high ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Florent Xicluna la...@yahoo.fr added the comment: Patch proposed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Florent Xicluna la...@yahoo.fr: -- keywords: +patch Added file: http://bugs.python.org/file15936/issue7732_find_module.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file15936/issue7732_find_module.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py
Florent Xicluna la...@yahoo.fr added the comment: Removed the EnvironmentVarGuard from the test. It does not make sense. -- Added file: http://bugs.python.org/file15937/issue7732_find_module.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7732 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com