This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mmap: don't close file description if fd=-1
Type: Stage:
Components: Extension Modules Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ocean-city, vstinner
Priority: normal Keywords: patch

Created on 2009-06-12 10:50 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
warn.py vstinner, 2009-06-12 10:50
mmap_close.patch vstinner, 2009-06-12 10:51
Messages (2)
msg89269 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-06-12 10:50
Hi, Valgrind just told me that Python calls close(-1) on
my_mmap_object.close() for memory mappings. That's because a memory
mapping has no (related) file descriptor.

Using attached warn.py, you can see the warning using strace:

$ strace -e close python warn.py 2>&1|grep -A1 12345
close(12345)                            = -1 EBADF (Bad file descriptor)
close(4294967295)                       = -1 EBADF (Bad file descriptor)
close(12345)                            = -1 EBADF (Bad file descriptor)

where close(4294967295) means close(-1).

Attached patch fixes this warning.
msg89341 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-06-14 05:17
Thanks, fixed in r73425(trunk), r73426(release26-maint), r73427(py3k),
r73428(release30-maint).
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50520
2009-06-14 05:18:19ocean-citysetstatus: open -> closed
resolution: fixed
2009-06-14 05:17:20ocean-citysetnosy: + ocean-city
messages: + msg89341
2009-06-12 10:51:36vstinnersetfiles: + mmap_close.patch
2009-06-12 10:51:27vstinnersetfiles: - mmap_close.patch
2009-06-12 10:51:21vstinnersetfiles: - warn.py
2009-06-12 10:51:16vstinnersetfiles: + warn.py
2009-06-12 10:50:38vstinnersetfiles: + mmap_close.patch
keywords: + patch
2009-06-12 10:50:28vstinnercreate