-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Assertion failure for socket
with too large default timeout (larger than INT_MAX)
#126876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
3.12
only security fixes
3.13
bugs and security fixes
3.14
bugs and security fixes
extension-modules
C modules in the Modules dir
type-crash
A hard crash of the interpreter, possibly with a core dump
Comments
Here's my idea: diff --git Modules/socketmodule.c Modules/socketmodule.c
index 2764bd6e2b2..4c0aac92a76 100644
--- Modules/socketmodule.c
+++ Modules/socketmodule.c
@@ -810,7 +810,7 @@ internal_select(PySocketSockObject *s, int writing, PyTime_t interval,
/* s->sock_timeout is in seconds, timeout in ms */
ms = _PyTime_AsMilliseconds(interval, _PyTime_ROUND_CEILING);
- assert(ms <= INT_MAX);
+ assert(ms <= PyTime_MAX);
/* On some OSes, typically BSD-based ones, the timeout parameter of the
poll() syscall, when negative, must be exactly INFTIM, where defined,
After that:
|
If others agree with me - I can open a PR :) |
This change is wrong: poll() last argument type is diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 2764bd6e2b2..0ba5b4af6bc 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -810,7 +810,9 @@ internal_select(PySocketSockObject *s, int writing, PyTime_t interval,
/* s->sock_timeout is in seconds, timeout in ms */
ms = _PyTime_AsMilliseconds(interval, _PyTime_ROUND_CEILING);
- assert(ms <= INT_MAX);
+ if (ms > INT_MAX) {
+ ms = INT_MAX;
+ }
/* On some OSes, typically BSD-based ones, the timeout parameter of the
poll() syscall, when negative, must be exactly INFTIM, where defined, |
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 18, 2024
If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test.
I propose PR gh-126968 to fix the issue. |
socket._fallback_socketpair
with too large default timeoutsocket
with too large default timeout (larger than INT_MAX)
socket
with too large default timeout (larger than INT_MAX)socket
with too large default timeout (larger than INT_MAX)
vstinner
added a commit
that referenced
this issue
Nov 19, 2024
If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Nov 19, 2024
…onGH-126968) If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test. (cherry picked from commit b3687ad) Co-authored-by: Victor Stinner <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Nov 19, 2024
…onGH-126968) If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test. (cherry picked from commit b3687ad) Co-authored-by: Victor Stinner <[email protected]>
This was referenced Nov 19, 2024
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Dec 2, 2024
vstinner
added a commit
that referenced
this issue
Dec 2, 2024
vstinner
added a commit
to miss-islington/cpython
that referenced
this issue
Dec 2, 2024
…capi (python#127517) (cherry picked from commit c46acd3)
vstinner
added a commit
to miss-islington/cpython
that referenced
this issue
Dec 2, 2024
…capi (python#127517) (cherry picked from commit c46acd3)
Can this be closed? All linked PRs have been merged. |
srinivasreddy
pushed a commit
to srinivasreddy/cpython
that referenced
this issue
Jan 8, 2025
ebonnal
pushed a commit
to ebonnal/cpython
that referenced
this issue
Jan 12, 2025
…on#126968) If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test.
ebonnal
pushed a commit
to ebonnal/cpython
that referenced
this issue
Jan 12, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.12
only security fixes
3.13
bugs and security fixes
3.14
bugs and security fixes
extension-modules
C modules in the Modules dir
type-crash
A hard crash of the interpreter, possibly with a core dump
Uh oh!
There was an error while loading. Please reload this page.
Crash report
What happened?
A debug build will abort when calling
socket._fallback_socketpair()
after a call tosocket.setdefaulttimeout
with too high a value:Found using fusil by @vstinner.
CPython versions tested on:
3.12, 3.13, 3.14, CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.13.0+ (heads/3.13:7be8743, Nov 15 2024, 15:20:16) [GCC 13.2.0]
Linked PRs
The text was updated successfully, but these errors were encountered: