arnaud-lb
Repos
172
Followers
327
Following
52

The PHP Interpreter

C
34369
7008

PHP Static Analysis Tool - discover bugs in your code without running it!

11347
782

Production-ready, stable Kafka client for PHP

C
1841
259

Memory profiler for PHP. Helps finding memory leaks in PHP scripts.

C
699
43

php-go allows to call Go code from PHP, with minimal code boilerplate

C
162
17

PHP namespace support for VIM. Types "use" statements for you

254
29

Events

issue comment
segmentation fault when sending SIGINT to PHP embedded in another program

There is a good chance that the signal handler is being invoked on a thread that didn't execute PHP. In this case, per-thread resources have not been initialized on the thread, so SIGG(active) dereferences an invalid pointer.

I can reproduce the issue with this: https://gist.github.com/arnaud-lb/d0f2282e66def91a6ee34e1537b3ac5f

I'm assuming that there is no way to install hooks in Go's thread creations.

One way to prevent this crash would be to mask all signals in all threads except the ones that are ready to handle signals.

An other way would be to disable ZEND_SIGNAL entirely (--disable-zend-signals). Its purpose is to prevent corruption of shared state (such as the opcache) in forking SAPIs, but I believe that it's unnecessary when running a single process. In a multi-process setup, a process could be terminated while in the middle of updating the shared state. This would leave other processes with a corrupted state. In a single-process setup, this doesn't matter.

Created at 20 hours ago
closed issue
stream_select does not abort upon exception or empty valid fd set

Description

The following code:

<?php

$fds = [];
for ($i = 0; $i < 1023; $i++) {
    $fds[] = fopen("/tmp/__0_a_evil_tmpfile.$i", 'w');
}

list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);

$r = [$a];
$w = $e = [];
var_dump(stream_select($r, $w, $e, PHP_INT_MAX));

Will result in a hang, after printing the warning, with an empty select() syscall being emitted.

However, adding in an error handler throwing an exception, e.g. set_error_handler(function() { throw new \Exception; }); at the start will cause the warning not be printed and still hang indefinitely, hiding the issue very well.

(Original bug report at https://github.com/amphp/amp/issues/398)

PHP Version

PHP 7.4 - master

Operating System

No response

Created at 21 hours ago
issue comment
stream_select does not abort upon exception or empty valid fd set

Fixed in #9602

Created at 21 hours ago

GH-9464: Fix build on older macOs releases.

A simple check for CommonCrypto/CommonRandom.h does not work on earlier macOS. Must also pull in sys/types.h for size_t, Availability.h for __OSX_AVAILABLE_STARTING, and CommonCrypto/CommonCryptoError.h for CCCryptorStatus.

Closes GH-9479.

Merge branch 'PHP-8.2'

Remove obsolete checks for random-related functionality from ext/standard/config.m4 (#9482)

The users of these checks have been moved to ext/random. ext/standard does not reference the resulting defines.

posix add sysconf call.

providing handful of common and most used constants.

Closes GH-9481.

[ci skip] NEWS UPGRADING

[ci skip] UPGRADING striping name.

[ci skip] Fix formatting in UPGRADING

  • Remove k typo that was accidentally added in a headline separator.
  • Remove premature hard break after very short line length.
  • Remove dots at the end of constant lists (not used in 8.2).

Fix type inference

Fixes oss-fuzz #50792

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Fix type inference

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Fix type inference

Merge branch 'PHP-8.2'

  • PHP-8.2: Fix type inference

Fix inexistent skipif.inc

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Fix inexistent skipif.inc

Merge branch 'PHP-8.2'

  • PHP-8.1: Fix inexistent skipif.inc

Add support for validation of missing class synopses (#9472)

Merge branch 'PHP-8.2'

  • PHP-8.2: Add support for validation of missing class synopses (#9472)

Support sapi/cli/tests/017.phpt on Windows, too

escapeshellarg() is pretty useless on Windows, and there is no way to support multiple lines (i.e. line breaks). Thus, we use proc_open() instead of shell_exec().

We also remove some apparently superfluous empty lines from the test expectation; that seems to match libedit behavior on Linux.

Closes GH-9474.

Fix GH-9411: PgSQL large object resource is incorrectly closed

Co-authored-by: Christoph M. Becker cmbecker69@gmx.de

Closes GH-9411.

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Fix GH-9411: PgSQL large object resource is incorrectly closed

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Fix GH-9411: PgSQL large object resource is incorrectly closed
Created at 21 hours ago

GH-9464: Fix build on older macOs releases.

A simple check for CommonCrypto/CommonRandom.h does not work on earlier macOS. Must also pull in sys/types.h for size_t, Availability.h for __OSX_AVAILABLE_STARTING, and CommonCrypto/CommonCryptoError.h for CCCryptorStatus.

Closes GH-9479.

Fix type inference

Fixes oss-fuzz #50792

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Fix type inference

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Fix type inference

Fix inexistent skipif.inc

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Fix inexistent skipif.inc

Add support for validation of missing class synopses (#9472)

Fix GH-9411: PgSQL large object resource is incorrectly closed

Co-authored-by: Christoph M. Becker cmbecker69@gmx.de

Closes GH-9411.

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Fix GH-9411: PgSQL large object resource is incorrectly closed

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Fix GH-9411: PgSQL large object resource is incorrectly closed

random: Validate that the arrays do not contain extra elements when unserializing (#9458)

  • Apply var_dump() in 02_engine/all_serialize_error.phpt

This ensures that an undetected serialization error is clear identifiable in the output.

  • random: Validate that the arrays do not contain extra elements when unserializing

Update INI validator and displayers depending on INI type

Closes GH-9451

Update globals to use bool type

Add zend_string INI validators

Currently we only have validators for char* which is rather annoying as INI settings are saved as zend_string* in the first place

Closes GH-9328

Upgrade PHP parser to 4.15.1

It contains some useful fixes

Add support for validation of missing method synopses (#9491)

Fix GH-9493: fix ancillary data build for FreeBSD prior to the 13 release. (#9496)

the legacy sockcred struct does not hold the process id, thus sockcred2 had been added from FreeBSD 13 in conjunction with LOCAL_CREDS_PERSISTENT to address this thus we disable the feature for earlier releases.

Private method incorrectly marked as "overwrites" in reflection

Fix GH-9409 Closes GH-9469

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Private method incorrectly marked as "overwrites" in reflection

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Private method incorrectly marked as "overwrites" in reflection
Created at 21 hours ago

[ci skip] NEWS

Created at 21 hours ago

Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: [ci skip] NEWS Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: [ci skip] NEWS [ci skip] NEWS Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Merge branch 'PHP-8.2'

  • PHP-8.2: [ci skip] NEWS [ci skip] NEWS [ci skip] NEWS Return immediately when FD_SETSIZE is exceeded (#9602)
Created at 21 hours ago

Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: [ci skip] NEWS Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: [ci skip] NEWS [ci skip] NEWS Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Created at 21 hours ago

Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: [ci skip] NEWS Return immediately when FD_SETSIZE is exceeded (#9602)

[ci skip] NEWS

Created at 21 hours ago

Integrate timelib 2021.12

Adjust existing tests for fixed bugs

Fixed bug GH-7758 (Problems with negative timestamps and fractions)

Fixed bug #66019 (DateTime object does not support short ISO 8601 time format - YYYY-MM-DDTHH)

Fixed bug #68549 (Timezones and offsets are not properly used when working with dates)

Fixed bug #51934 (strtotime plurals / incorrect time)

Fixed bug #51987 (Datetime fails to parse an ISO 8601 ordinal date (extended format))

Fixed bug #81565 (date parsing fails when provided with timezones including seconds)

Merge remote-tracking branch 'derickr/merge-timelib-2021.12-and-add-tests' into PHP-8.1

Reduce the scope of XFAIL (#8592)

Fix undefined behavior in php_set_inet6_addr

Postfix ++ on NULL is undefined behavior

Closes GH-8607

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Fix undefined behavior in php_set_inet6_addr Reduce the scope of XFAIL (#8592)

[skip ci] Add NEWS entry

Fix GH-8538: SoapClient may strip parts of nmtokens

When stripping the namespace prefix, we can assume that this does not contain any colons, while the rest of the name may contain colons. Hence we must not use strrchr() but rather strchr() instead.

Closes GH-8543.

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Fix GH-8538: SoapClient may strip parts of nmtokens

Fix pcntl Haiku build

guarding SIGIO constant.

Closes GH-8612.

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Fix pcntl Haiku build

Fix mb_detect_encoding's recognition of Slavic names

Thanks to Côme Chilliet for reporting that mb_detect_encoding was not detecting the desired text encoding for strings containing š or Ž. These characters are used in Czech, Serbian, Croatian, Bosnian, Macedonian, etc. names.

Disable zend_rc_debug during dtor of dl()'ed module (#8606)

Newly added dl() tests trigger an assertion in ZEND_RC_DEBUG builds. This change disables zend_rc_debug to allows these tests to pass until this issue is resolved.

Bump for 8.0.21

Created at 21 hours ago

Return immediately when FD_SETSIZE is exceeded (#9602)

Created at 21 hours ago
pull request closed
Return immediately when FD_SETSIZE is exceeded

Fixes #9590

Created at 21 hours ago
issue comment
File descriptors / some procfs entries not openable by php

@SpencerMalone does it happen in some specific conditions?

I've tried reproducing it with this docker file, with no luck:

docker build -t gh9551 .
docker run -ti --rm gh9551:latest php -r 'file_put_contents("/proc/1/fd/1", "hi");'
Created at 1 day ago
pull request opened
Revert "Stop copying zend_module_entry (#8551)"

This reverts commit b63df3ce0e9f4eef94310aeb2ef7e8dfd0f953e4.

Created at 1 day ago

Fix #81727: Don't mangle HTTP variable names that clash with ones that have a specific semantic meaning.

Fix #81726: phar wrapper: DOS when using quine gzip file

The phar wrapper needs to uncompress the file; the uncompressed file might be compressed, so the wrapper implementation loops. This raises potential DOS issues regarding too deep or even infinite recursion (the latter are called compressed file quines[1]). We avoid that by introducing a recursion limit; we choose the somewhat arbitrary limit 3.

This issue has been reported by real_as3617 and gPayl0ad.

[1] https://honno.dev/gzip-quine/

Revert "Fix parse_url(): can not recognize port without scheme"

This reverts commit 72d83709d9524945c93012f7bbb222e412df485a.

Closes GH-9569

Migrate community job to GitHub actions

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Migrate community job to GitHub actions

Move Opcache variation job to GitHub actions

Closes GH-9606

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Move Opcache variation job to GitHub actions

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Move Opcache variation job to GitHub actions

Migrate MSAN build to GitHub actions

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Migrate MSAN build to GitHub actions

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Migrate MSAN build to GitHub actions

Migrate --repeat 2 job to GitHub actions

Migrate variation job to GitHub actions

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Migrate variation job to GitHub actions Migrate --repeat 2 job to GitHub actions

Migrate libmysqlclient job to GitHub actions

Closes GH-9608

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Migrate libmysqlclient job to GitHub actions

Remove symfony and laravel from PHP-8.0 community job

These branches no longer support PHP-8.0.

Merge branch 'PHP-8.0' into PHP-8.1

  • PHP-8.0: Remove symfony and laravel from PHP-8.0 community job

Merge branch 'PHP-8.1' into PHP-8.2

  • PHP-8.1: Remove symfony and laravel from PHP-8.0 community job

Remove unused azure pipelines templates

Created at 1 day ago
create branch
arnaud-lb create branch revert-8551
Created at 1 day ago
issue comment
A core dump (SIGSEGV) occurs when dl() is used

Smallest reproducer:

./configure --disable-all --enable-debug --enable-xml=shared --with-libxml --with-zlib=shared
make
sapi/cli/php -n -dextension_dir=$(pwd)/modules -dextension=xml.so -dextension=zlib.so -r 'dl("xml.so");'

The first commit that crash is b63df3ce0e9f4eef94310aeb2ef7e8dfd0f953e4

Backtrace:

0x000055555598bbbc in clean_module_class (el=0x555556339db0, arg=0x7fffffffda1c) at Zend/zend_API.c:2940
2940		if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module->module_number == module_number) {
(gdb) bt
#0  0x000055555598bbbc in clean_module_class (el=0x555556339db0, arg=0x7fffffffda1c) at Zend/zend_API.c:2940
#1  0x000055555599b04c in zend_hash_apply_with_argument (ht=0x555556234960, apply_func=0x55555598bb82 <clean_module_class>, argument=0x7fffffffda1c) at Zend/zend_hash.c:2044
#2  0x000055555598bc01 in clean_module_classes (module_number=12) at Zend/zend_API.c:2950
#3  0x000055555598bc56 in module_destructor (module=0x7ffff7fb3300 <xml_module_entry>) at Zend/zend_API.c:2960
#4  0x000055555597d46e in module_destructor_zval (zv=0x7fffffffdac0) at Zend/zend.c:844
#5  0x0000555555998d4d in _zend_hash_del_el_ex (ht=0x55555621a7e0 <module_registry>, idx=9, p=0x555556242bb0, prev=0x0) at Zend/zend_hash.c:1408
#6  0x0000555555998e47 in _zend_hash_del_el (ht=0x55555621a7e0 <module_registry>, idx=9, p=0x555556242bb0) at Zend/zend_hash.c:1435
#7  0x000055555599ac28 in zend_hash_graceful_reverse_destroy (ht=0x55555621a7e0 <module_registry>) at Zend/zend_hash.c:1960
#8  0x00005555559895b5 in zend_destroy_modules () at Zend/zend_API.c:2336
#9  0x000055555597d84e in zend_shutdown () at Zend/zend.c:1089
#10 0x00005555558d8aeb in php_module_shutdown () at main/main.c:2398
#11 0x0000555555afc115 in main (argc=7, argv=0x5555562343d0) at sapi/cli/php_cli.c:1347

Since this commit, the module entry lives in the shared library's data segment. This crashes because ce->info.internal.module points to the data segment of an unloaded module.

This happens when unloading a temporary module after a permanent module, which is normally not possible (modules are unloaded in reverse loading order). However, in this case module_entry->type of the xml module is set to MODULE_TEMPORARY when its loaded a second time.

Created at 1 day ago
pull request opened
Discard known '-O' flags, including just '-O', but do not remove only '-O' in '-Ounknown'

Fixes #9645

Created at 1 day ago
create branch
arnaud-lb create branch gh9645
Created at 1 day ago

Fix test

Created at 1 day ago
issue comment
Return immediately when FD_SETSIZE is exceeded

I have a preference for just returning when an exception is thrown, or for always returning when FD_SETSIZE is exceeded, over returning only when the fd set is empty. In the latter, the user may be under the impression that select() actually works despite the warning, because select() will monitor some FDs, but some others will not actually be monitored.

Returning only when an exception is thrown has the advantage of making the least behavioral changes while still fixing the original bug.

Returning when FD_SETSIZE also prevents hanging forever (in the case where the set is empty), and makes the problem more visible (if the warning is not spotted already).

Created at 1 day ago

Improve warning message

Created at 1 day ago

Missing test file

Created at 1 day ago

Add tests

Created at 1 day ago