Title: Off-by-one error in _winapi.WaitForMultipleObjects · Issue #94242 · python/cpython · GitHub
Open Graph Title: Off-by-one error in _winapi.WaitForMultipleObjects · Issue #94242 · python/cpython
X Title: Off-by-one error in _winapi.WaitForMultipleObjects · Issue #94242 · python/cpython
Description: Bug report _winapi_WaitForMultipleObjects_impl in _winapi.c creates an array of MAXIMUM_WAIT_OBJECTS handles but then arbitrarily enforces a cap of MAXIMUM_WAIT_OBJECTS - 1 handles. This is incorrect. WaitForMultipleObjects is clearly do...
Open Graph Description: Bug report _winapi_WaitForMultipleObjects_impl in _winapi.c creates an array of MAXIMUM_WAIT_OBJECTS handles but then arbitrarily enforces a cap of MAXIMUM_WAIT_OBJECTS - 1 handles. This is incorre...
X Description: Bug report _winapi_WaitForMultipleObjects_impl in _winapi.c creates an array of MAXIMUM_WAIT_OBJECTS handles but then arbitrarily enforces a cap of MAXIMUM_WAIT_OBJECTS - 1 handles. This is incorre...
Opengraph URL: https://github.com/python/cpython/issues/94242
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Off-by-one error in _winapi.WaitForMultipleObjects","articleBody":"**Bug report**\r\n\r\n_winapi_WaitForMultipleObjects_impl in _winapi.c creates an array of MAXIMUM_WAIT_OBJECTS handles but then arbitrarily enforces a cap of MAXIMUM_WAIT_OBJECTS - 1 handles. This is incorrect. WaitForMultipleObjects is clearly documented as being able to handle MAXIMUM_WAIT_OBJECTS (64) handles. This simple C++ sample code demonstrates this:\r\n\r\n#include \u003cstdio.h>\r\n#include \u003cwindows.h>\r\n\r\n#include \u003cvector>\r\n\r\nint main(int argc, char* argv[]) {\r\n for (DWORD count = 60; count \u003c 66; ++count) {\r\n printf(\"About to wait on %d handles.\\n\", count);\r\n std::vector\u003cHANDLE> handles(count);\r\n for (int i = 0; i \u003c count; ++i)\r\n handles[i] = CreateEventW(nullptr, FALSE, TRUE, nullptr);\r\n DWORD wait_result = WaitForMultipleObjects(count, handles.data(), TRUE, INFINITE);\r\n if (wait_result == WAIT_OBJECT_0)\r\n printf(\" Wait satisfied by object 0.\\n\");\r\n else if (wait_result == WAIT_FAILED)\r\n printf(\" Wait failed.\\n\");\r\n else\r\n printf(\" Result was %lu.\\n\", wait_result);\r\n for (int i = 0; i \u003c count; ++i)\r\n CloseHandle(handles[i]);\r\n }\r\n}\r\n\r\nThis error also shows up here:\r\nhttps://github.com/python/cpython/commit/39889864c09741909da4ec489459d0197ea8f1fc#diff-eb5cd13d65d2f215d8dc0d95eb1a1341ff69b226ac56ec6099e39582edecc8cfR219\r\nand here:\r\nhttps://github.com/python/cpython/commit/39889864c09741909da4ec489459d0197ea8f1fc#diff-84a955ea642d41d9f164e9f94499d8eb33c357ec7f4362a341951f6f67ab21a1R117\r\n\r\nNote that this is in addition to the off-by-one error that was tracked by this issue:\r\nhttps://github.com/python/cpython/issues/84444\r\n\r\nThat is, there used to be an off-by-two error (maximum of 60 processes could be waited on) and now there is an off-by-one error (maximum of 61 processes can be waited on). In Python 3.8.10 the limit is still 60, but in Python 3.9 the limit is (as far as I can tell) 61. It should be 62.\r\n\r\n**Your environment**\r\n\r\nPython 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32\r\nWindows 10\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-135537\n* gh-156905\n* gh-156906\n* gh-156907\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/randomascii","@type":"Person","name":"randomascii"},"datePublished":"2022-06-24T20:15:58Z","url":"https://github.com/python/cpython/issues/94242"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a1a138de-dab7-ec73-6be8-0d5446226cc3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87FC:2679E9:321E30C:42EB09B:6B01F762 |
| html-safe-nonce | 2aed5f9981b24e5e26a857658c8373d9357ef69240c416008be134b55c57be80 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0ZDOjI2NzlFOTozMjFFMzBDOjQyRUIwOUI6NkIwMUY3NjIiLCJ2aXNpdG9yX2lkIjoiNTk5MzgxMTMxNTAyODc4NDk5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6ee5cb8d03e4a85d99ff40e30d15077fd47b8d3044f22167170b73c76fd8ad09 |
| hovercard-subject-tag | issue:1284148109 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/94242/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3af9980438ac8b1e940d2ac1c61070ac4964e16b2c4b4656cf566d26abe95f0a/python/cpython/issues/94242 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3af9980438ac8b1e940d2ac1c61070ac4964e16b2c4b4656cf566d26abe95f0a/python/cpython/issues/94242 |
| og:image:alt | Bug report _winapi_WaitForMultipleObjects_impl in _winapi.c creates an array of MAXIMUM_WAIT_OBJECTS handles but then arbitrarily enforces a cap of MAXIMUM_WAIT_OBJECTS - 1 handles. This is incorre... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | randomascii |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width