Skip to content

Force macOS to use statfs. #8054

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
wants to merge 4,546 commits into from
Closed

Force macOS to use statfs. #8054

wants to merge 4,546 commits into from

Conversation

risner
Copy link
Contributor

@risner risner commented Feb 7, 2022

A macOS bug in libc statvfs(3) call truncates 64 bit elements (e.g. f_blocks) to 32 bits.

Tested in php@7.4, but it is a clean patch against the current.

t.php:
echo "Total: " . disk_total_space("/Volumes/Data/H1/tank"), PHP_EOL;
echo "Free: " . disk_free_space("/Volumes/Data/H1/tank"), PHP_EOL;

Test results:
mbpm1# df -k/Volumes/Data/H1/tank
Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
h1:/tank 30259027086 21624936060 8634091026 72% 218 17268182053 0% /System/Volumes/Data/H1/tank

mbpm1# php t.php
Total: 30985243736576
Free: 8841309211136

30985243736576 ~ 302590270861024 off by 512.
8841309211136 ~ 8634091026
1024 also off by 512.

TysonAndre and others added 30 commits December 19, 2021 10:12
… how to test the jit in different architectures. (php#7768)
* PHP-8.0:
  Fix FILTER_FLAG_NO_RES_RANGE flag
* PHP-8.1:
  Fix FILTER_FLAG_NO_RES_RANGE flag
* PHP-8.0:
  [ci skip] Fix "The Mysterious PHP RFC Process" link.
* PHP-8.1:
  [ci skip] Fix "The Mysterious PHP RFC Process" link.
* PHP-8.0:
  Fix type inference for INIT_ARRAY with invalid index
* PHP-8.1:
  Fix type inference for INIT_ARRAY with invalid index
* PHP-8.0:
  JIT: Fix register clobbering
* PHP-8.1:
  JIT: Fix register clobbering
* PHP-8.0:
  Fix incorrect optimization of ASSIGN_OP that may lead to memory leak
* PHP-8.1:
  Fix incorrect optimization of ASSIGN_OP that may lead to memory leak
Avoids (Solaris SPARC) issue:
  zend_fibers.c:77:9: error: unknown type name 'ucontext_t'

Closes phpGH-7773.
* PHP-8.1:
  Fix zend_fibers.c build with ZEND_FIBER_UCONTEXT
get/set the cpu attached to a socket, no special treatment needed,
it is simply an integer.

Closes phpGH-7753.
…uation, add functions. (php#7780)

https://wiki.php.net/rfc/strtolower-ascii means that these functions no longer
depend on the current locale in php 8.2. Before that, this was unsafe to
evaluate at compile time.

Followup to phpGH-7506

Add strcmp/strcasecmp/strtolower/strtoupper functions

Add bin2hex/hex2bin and related functions

Update test of garbage collection using strtolower to use something else to create a refcounted string
…se64, QPrint

In a2bc57e, mb_detect_encoding was modified to ensure it would never
return 'UUENCODE', 'QPrint', or other non-encodings as the "detected
text encoding". Before mb_detect_encoding was enhanced so that it could
detect any supported text encoding, those were never returned, and they
are not desired. Actually, we want to eventually remove them completely
from mbstring, since PHP already contains other implementations of
UUEncode, QPrint, Base64, and HTML entities.

For more clarity on why we need to suppress UUEncode, etc. from being
detected by mb_detect_encoding, the existing UUEncode implementation
in mbstring *never* treats any input as erroneous. It just accepts
everything. This means that it would *always* be treated as a valid
choice by mb_detect_encoding, and would be returned in many, many cases
where the input is obviously not UUEncoded.

It turns out that the form of mb_convert_encoding where the user passes
multiple candidate encodings (and mbstring auto-detects which one to
use) was also affected by the same issue. Apply the same fix.
* PHP-8.1:
  mb_convert_encoding will not auto-detect input string as UUEncode, Base64, QPrint
* PHP-8.0:
  JIT: Fix incorrect JIT prologur size for CLANG/x86 build
* PHP-8.1:
  JIT: Fix incorrect JIT prologur size for CLANG/x86 build
* PHP-8.0:
  Fixed compilation warning
* PHP-8.1:
  Fixed compilation warning
* PHP-8.0:
  zend gdb detection fix on FreeBSD.
* PHP-8.1:
  zend gdb detection fix on FreeBSD.
* PHP-8.0:
  socket: ancillary credentials build fix for non linux systems.
* PHP-8.1:
  socket: ancillary credentials build fix for non linux systems.
iluuu1994 and others added 23 commits January 31, 2022 21:44
Closes phpGH-7847
Closes phpGH-7852

Previously stripos/stristr would lowercase both the haystack and the
needle to reuse strpos. The approach in this PR is similar to strpos.
memchr is highly optimized so we're using it to search for the first
character of the needle in the haystack. If we find it we compare the
remaining characters of the needle manually.

The new implementation seems to perform about half as well as strpos (as
two memchr calls are necessary to find the next candidate).
* PHP-8.0:
  Fix memory leak
* PHP-8.1:
  Fix memory leak
* PHP-8.1:
  Prevent array modification if it's captured by user error handler during index conversion
* PHP-8.0:
  JIT: Fix register alloction (missed store)
* PHP-8.1:
  JIT: Fix register alloction (missed store)
* PHP-8.0:
  Bump for 8.0.17-dev
* PHP-8.1:
  Bump for 8.0.17-dev
Pull requests with the "Waiting on Author" label should still not be
closed if they have the RFC label as closing them requires manual
action. Also avoid closing "Waiting on Review".
* PHP-8.1:
  Bump for 8.1.4-dev
* PHP-8.0:
  Fix phpGH-7953: ob_clean() only does not set Content-Encoding
* PHP-8.1:
  Fix phpGH-7953: ob_clean() only does not set Content-Encoding
)

Don't call fchmod(-1), which is not only wrong, but also clobbers
errno and sets it to EBADF, breaking the following errno access for
the log message.
`error: comparison of integer expressions of different signedness: ‘size_t’ {aka
‘long unsigned int’} and ‘long int’ [-Werror=sign-compare]`

This is asserting `end >= haystack` as a precondition for callers (in debug
builds) and existing callers are correct.

An alternate option is to cast the left side to `int64_t`, but that may be
slightly inefficient for 32-bit builds.
* PHP-8.0:
  Haiku fix ZTS build, disabling tls model
* PHP-8.1:
  Haiku fix ZTS build, disabling tls model
* PHP-8.0:
  Fix phpGH-7980: Unexpected result for iconv_mime_decode
* PHP-8.1:
  Fix phpGH-7980: Unexpected result for iconv_mime_decode
A macOS bug in libc statvfs(3) call truncates 64 bit elements (e.g. f_blocks) to 32 bits.
// Apple statvfs has an interger overflow in libc copying to statvfs.
// cvt_statfs_to_statvfs(struct statfs *from, struct statvfs *to) {
// to->f_blocks = (fsblkcnt_t)from->f_blocks;
#undef HAVE_SYS_STATVFS_H
Copy link
Member

Choose a reason for hiding this comment

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

I may suggest, for style consistency, to have spaces like above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I'm following your suggestion correctly, I've made a patch to match styles.

Copy link
Member

Choose a reason for hiding this comment

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

thank you !

Copy link
Member

Choose a reason for hiding this comment

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

since it is a bug fix however I may suggest to target PHP-8.0 instead.

Copy link
Contributor Author

@risner risner Feb 7, 2022

Choose a reason for hiding this comment

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

8.0.15? or 8.0?

Copy link
Member

Choose a reason for hiding this comment

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

PHP-8.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed. New PR #8056

Copy link
Member

Choose a reason for hiding this comment

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

I had not noticed you created from your own master branch. it might be better to recreate your patch/PR from PHP-8.0 but with a distinct branch.

@risner risner changed the base branch from master to PHP-8.0 February 7, 2022 17:14
@risner risner marked this pull request as draft February 7, 2022 17:24
@risner
Copy link
Contributor Author

risner commented Feb 7, 2022

Changed branches, new PR #8056

@risner risner closed this Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.