Skip to content

UBSan abort in ext/sockets/sockets.c:373 #16267

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

Closed
YuanchengJiang opened this issue Oct 6, 2024 · 2 comments
Closed

UBSan abort in ext/sockets/sockets.c:373 #16267

YuanchengJiang opened this issue Oct 6, 2024 · 2 comments

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
socket_strerror(-2147483648);

Resulted in this output:

/php-src/ext/sockets/sockets.c:373:11: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/sockets/sockets.c:373:11

Such bugs look nonsensical to me. Shall I keep reporting them?

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

@devnexen devnexen self-assigned this Oct 6, 2024
devnexen added a commit to devnexen/php-src that referenced this issue Oct 6, 2024
only socket_strerror provides user-supplied value to sockets_strerror
handler.
@devnexen devnexen linked a pull request Oct 6, 2024 that will close this issue
devnexen added a commit to devnexen/php-src that referenced this issue Oct 6, 2024
only socket_strerror provides user-supplied value to sockets_strerror
handler.
@YuanchengJiang
Copy link
Author

it happens again in the latest commit

@devnexen
Copy link
Member

devnexen commented Nov 28, 2024

I can t reproduce with last master, how does it look to you in ext/sockets/sockets.c around line 1258 (I assume you run 64 bits ubuntu) ? Actually I can, will make a PR

devnexen added a commit to devnexen/php-src that referenced this issue Nov 28, 2024
boundaries should be INT_MIN <= val < INT_MAX in fact.
devnexen added a commit to devnexen/php-src that referenced this issue Dec 9, 2024
boundaries should be INT_MIN <= val < INT_MAX in fact.
devnexen added a commit that referenced this issue Dec 9, 2024
boundaries should be INT_MIN <= val < INT_MAX in fact.

close GH-16891
charmitro pushed a commit to wasix-org/php that referenced this issue Mar 13, 2025
boundaries should be INT_MIN <= val < INT_MAX in fact.

close phpGH-16891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants