-
Notifications
You must be signed in to change notification settings - Fork 7.8k
ASAN UndefinedBehaviorSanitizer when timeout = -1 passed to stream_socket_accept/stream_socket_client #11177
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
Comments
Reproducible with Clang, not GCC strangely. |
Closed
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
May 2, 2023
…viour A negative value like -1 may overflow and cause incorrect results in the timeout variable, which causes an immediate timeout. As this is caused by undefined behaviour the exact behaviour depends on the compiler, its version, and the platform. A large overflow is also possible, if an extremely large timeout value is passed we also set an indefinite timeout. This is because the timeout value is at least a 64-bit number and waiting for UINT64_MAX/1000000 seconds is waiting about 584K years.
nielsdos
added a commit
that referenced
this issue
May 3, 2023
A negative value like -1 may overflow and cause incorrect results in the timeout variable, which causes an immediate timeout. As this is caused by undefined behaviour the exact behaviour depends on the compiler, its version, and the platform. A large overflow is also possible, if an extremely large timeout value is passed we also set an indefinite timeout. This is because the timeout value is at least a 64-bit number and waiting for UINT64_MAX/1000000 seconds is waiting about 584K years. Closes GH-11183.
nielsdos
added a commit
that referenced
this issue
May 3, 2023
nielsdos
added a commit
that referenced
this issue
May 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The following code with ASAN enabled:
Resulted in this output:
But I expected this output instead:
With the offending line being in stream_socket_accept modifying the timeout value and assigning a negative value to an unsigned long long (php_timeout_ull)
The same code and ASAN error can also be seen in stream_socket_client
PHP Version
PHP 8.2.5
Operating System
No response
The text was updated successfully, but these errors were encountered: