classification
Title: os.posix_fallocate() generate exception with errno 0
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mariatta, haypo, larry, serhiy.storchaka, socketpair
Priority: normal Keywords:

Created on 2017-08-02 15:03 by socketpair, last changed 2017-08-14 22:14 by larry.

Pull Requests
URL Status Linked Edit
PR 3000 merged socketpair, 2017-08-04 12:37
PR 3088 closed larry, 2017-08-14 13:59
Messages (11)
msg299660 - (view) Author: Марк Коренберг (socketpair) * Date: 2017-08-02 15:03
===
os.posix_fallocate(os.open('qwe.qwe', os.O_RDONLY|os.O_CREAT), 0, 1024*1024)
===

generates OSError with errno 0. Suppose this happen due to O_RDONLY flag.

strace :

====
open("qwe.qwe", O_RDONLY|O_CREAT|O_CLOEXEC, 0777) = 3
fallocate(3, 0, 0, 1048576)             = -1 EBADF (Bad file descriptor)
====


Python 3.5.3, Ubuntu 64-bit.
msg299740 - (view) Author: Марк Коренберг (socketpair) * Date: 2017-08-04 11:58
man posix_fallocate:

RETURN VALUE

posix_fallocate() returns zero on success, or an error number on failure.  Note that errno is not set.
msg299741 - (view) Author: Марк Коренберг (socketpair) * Date: 2017-08-04 12:12
Also, EINTR will not be caught too (!)
msg299742 - (view) Author: Марк Коренберг (socketpair) * Date: 2017-08-04 12:38
https://github.com/python/cpython/pull/3000
msg299746 - (view) Author: Марк Коренберг (socketpair) * Date: 2017-08-04 13:09
All checks passed.

Please merge.
msg299747 - (view) Author: Марк Коренберг (socketpair) * Date: 2017-08-04 13:20
posix_fadvise() is also affected :(

Fixed in this patch.
msg299830 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-08-07 08:23
Adding Larry who is listed as posix expert.
msg300244 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2017-08-14 13:55
New changeset d4b93e21c2664d6a78e0656e7a7be0807be1c352 by larryhastings (Коренберг Марк) in branch 'master':
bpo-31106: Fix handling of erros in posix_fallocate() and posix_fadvise() (#3000) (#3000)
https://github.com/python/cpython/commit/d4b93e21c2664d6a78e0656e7a7be0807be1c352
msg300259 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-14 18:09
Needed a NEWS entry.
msg300264 - (view) Author: Марк Коренберг (socketpair) * Date: 2017-08-14 20:39
If I understand right, Python 3.5 will not be fixed with this pathc. Right ?

If yes, I will tell Debian maintainers to backport this patch to Python 3.5, which is shipped with latest stable Debian 9.
msg300266 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2017-08-14 22:14
You understand correctly.  It won't be backported to Python 3.5.
History
Date User Action Args
2017-08-14 22:14:15larrysetmessages: + msg300266
2017-08-14 20:39:24socketpairsetmessages: + msg300264
2017-08-14 18:09:36serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg300259
versions: - Python 3.5
2017-08-14 13:59:16larrysetpull_requests: + pull_request3129
2017-08-14 13:55:19larrysetmessages: + msg300244
2017-08-07 09:09:47hayposetnosy: + haypo
2017-08-07 08:23:53Mariattasetnosy: + Mariatta, larry

messages: + msg299830
stage: patch review
2017-08-04 13:20:05socketpairsetmessages: + msg299747
2017-08-04 13:09:56socketpairsetmessages: + msg299746
2017-08-04 12:38:50socketpairsetmessages: + msg299742
2017-08-04 12:37:31socketpairsetpull_requests: + pull_request3036
2017-08-04 12:12:23socketpairsetmessages: + msg299741
2017-08-04 11:58:39socketpairsetmessages: + msg299740
2017-08-02 15:03:06socketpaircreate