Skip to content
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

Fix GH-17208: bug64539-status-json-encoding.phpt fail on 32-bits #17286

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

The reason this breaks is because of a type mismatch. The following line uses fields of the timeval struct which are both 8 bytes on Alpine 32-bit, which results in a computed value of also 8 bytes:

duration.tv_sec * 1000000UL + duration.tv_usec,

However, it is passed to a format string which expects 4 bytes (unsigned long and thus the %lu format specifier is 4 bytes on Alpine 32-bit), resulting in argument corruption.
Since the value is generally small, truncating to 4 bytes is sufficient to fix this.

@nielsdos nielsdos requested a review from bukka as a code owner December 27, 2024 15:42
@nielsdos nielsdos linked an issue Dec 27, 2024 that may be closed by this pull request
The reason this breaks is because of a type mismatch.
The following line uses fields of the timeval struct which are both 8 bytes on
Alpine 32-bit, which results in a computed value of also 8 bytes:
https://github.com/php/php-src/blob/b09ed9a0f25cda8c9eea9d140c01587cd50b4aa8/sapi/fpm/fpm/fpm_status.c#L611

However, it is passed to a format string which expects 4 bytes
(`unsigned long` and thus the `%lu` format specifier is 4 bytes on Alpine 32-bit),
resulting in argument corruption.
Since the value is generally small, truncating to 4 bytes is sufficient to fix this.
@nielsdos nielsdos closed this in 847d140 Dec 27, 2024
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.

bug64539-status-json-encoding.phpt fail on 32-bits
2 participants