Title: Sloppy error checking in listdir() for Posix
Type: crash Stage:
Components: Extension Modules Versions: Python 3.0, Python 2.6, Python 2.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: duaneg, georg.brandl, loewis, schmir, sdeibel, zanella
Priority: high Keywords: easy, patch

Created on 2006-12-04 22:34 by sdeibel, last changed 2008-07-16 21:31 by georg.brandl. This issue is now closed.

File name Uploaded Description Edit
proposed-patch.txt sdeibel, 2006-12-04 22:34 Possible less brittle way to implement this
fix-unicode-listdir.patch duaneg, 2008-06-04 13:11 Fixed and tested version of original proposed patch
Messages (4)
msg30743 - (view) Author: Stephan R.A. Deibel (sdeibel) Date: 2006-12-04 22:34
In the Linux/Unix (non-Windows / non-OS2) implementation of listdir() in posixmodule.c, a check for errno != 0 is done after the loop.  This assumes that errno is only set by readdir() but in fact it's possible for it to be set in PyUnicode_FromEncodedObject() if codecs are used in the conversion (actually that's a separate bug I'll report when I've investigated it futher).

To tighten this up, I'd recommend moving the errno != 0 clause in its entirety to just after the readdir() call and possibly resetting errno=0 before the readdir() call so it's clear the error really happened there.

I've attached a possible patch for this.
msg67690 - (view) Author: Duane Griffin (duaneg) * Date: 2008-06-04 13:11
This bug hit one of our (Gentoo) users, causing random failures when
running emerge (Gentoo's package management tool). See the bug report
here for more information:

Unfortunately the patch given previously is slightly broken. Please find
attached a working version that has survived testing and fixes the
problem for the bug reporter.
msg68983 - (view) Author: Rafael Zanella (zanella) Date: 2008-06-30 01:12
Related/Similar: #3115
msg69840 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-16 21:31
Fixed in r65037.
Date User Action Args
2008-07-16 21:31:51georg.brandlsetstatus: open -> closed
nosy: + georg.brandl
resolution: fixed
messages: + msg69840
2008-06-30 01:12:18zanellasetnosy: + zanella
messages: + msg68983
2008-06-04 20:53:35georg.brandlsetversions: + Python 2.6, Python 3.0
nosy: + loewis
priority: normal -> high
assignee: loewis
components: + Extension Modules, - Library (Lib)
keywords: + easy
type: crash
2008-06-04 20:38:46schmirsetnosy: + schmir
2008-06-04 13:11:08duanegsetfiles: + fix-unicode-listdir.patch
keywords: + patch
messages: + msg67690
nosy: + duaneg
2006-12-04 22:34:06sdeibelcreate