Skip to content

Conversation

nielsdos
Copy link
Member

The x86-32 build uses a fast path, but when I disabled the fast path I got the following compile error with -Werror:
mysqlnd_portability.h:221:95: error: right shift count >= width of type [-Werror=shift-count-overflow]

For 32-bit platforms that don't have the fast path, this can cause undefined behaviour at runtime. Some CPUs just mask the shift amount so in those cases you even get wrong results.
This is not always found during the build because -Werror is off by default.

@mvorisek
Copy link
Contributor

Can -Werror be tested using CI?

@nielsdos
Copy link
Member Author

Can -Werror be tested using CI?

This is already done for at least macOS and Linux x86(-64) builds. I don't know about the others.
I also don't know for sure if there might be platforms where PHP runs on that don't get tested in CI.

The x86-32 build uses a fast path, but when I disabled the fast path I
got the following compile error with -Werror:
mysqlnd_portability.h:221:95: error: right shift count >= width of type [-Werror=shift-count-overflow]

For 32-bit platforms that don't have the fast path, this can cause
undefined behaviour at runtime. Some CPUs just mask the shift amount
so in those cases you even get wrong results.
This is not always found during the build because -Werror is off by
default.
@nielsdos nielsdos changed the base branch from PHP-8.1 to PHP-8.2 April 3, 2024 17:27
@nielsdos nielsdos requested a review from SakiTakamachi April 3, 2024 17:27
Copy link
Member

@SakiTakamachi SakiTakamachi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@kamil-tekiela kamil-tekiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope it's fine. It makes sense to me.

@nielsdos nielsdos merged commit 8bfde5d into php:PHP-8.2 Apr 4, 2024
nielsdos added a commit that referenced this pull request Apr 4, 2024
* PHP-8.2:
  [ci skip] NEWS
  Fix shift out of bounds on 32-bit non-fast-path platforms (#10941)
nielsdos added a commit that referenced this pull request Apr 4, 2024
* PHP-8.3:
  [ci skip] NEWS
  Fix shift out of bounds on 32-bit non-fast-path platforms (#10941)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants