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

[RFC] Allow more money symbols #101

Open
wants to merge 1,362 commits into
base: master
Choose a base branch
from
Open

[RFC] Allow more money symbols #101

wants to merge 1,362 commits into from

Conversation

nielsdos
Copy link
Owner

@nielsdos nielsdos commented Apr 1, 2024

No description provided.

devnexen and others added 30 commits February 27, 2024 00:31
* Fixed int32 underflow on DateTime::createFromTimestamp
* PHP-8.3:
  PHP-8.2 is now for PHP 8.2.18-dev
* PHP-8.3:
  ext/pdo: Fix various PDORow bugs
The PHP_CHECK_GCC_ARG has been already removed in PHP 8.0 and this also
removes the error emitting wrapper.

Patches for the solr and vld extensions have been sent upstream.
* PHP-8.3:
  Fix phpGH-13517: Multiple test failures when building with --with-expat
* PHP-8.3:
  Fix phpGH-13531: Unable to resize SplfixedArray after being unserialized in PHP 8.2.15
The clock_gettime() is found in libc on modern systems, except on
Solaris <= 10 and possible similar systems, it is in the rt library.

This checks if clock_gettime() exists in the libc, then it checks if rt
library has clock_gettime, prepends it to LIBS and defines the
HAVE_CLOCK_GETTIME symbol with the template from the AC_CHECK_FUNCS.

The ac_cv_func_clock_gettime is a cache variable set by AC_CHECK_FUNCS.
Those are likely link from elsewhere so we could keep them
For Solaris/illumos systems, in this case, the check can be done using
AC_SEARCH_LIBS, which avoids defining redundant symbols like HAVE_PGRAB
and HAVE_LIBPROC.
This removes redundant symbols HAVE_LIBUTIL and HAVE_LIBBSD.
* PHP-8.3:
    Removed `REPORT_EXIT_STATUS=no` in libmysql tests
* random: Expose xoshiro256**'s seeding functions

* random: Expose pcgoneseq128xslrr64's seeding functions

* random: Expose Mt19937's seeding functions

* random: Expose CombinedLCG's seeding functions

* random: Call php_random_mt19937_seed32 to seed the global Mt19937

This avoids the function pointer indirection and improves type safety.

* random: NULL the generic seeding function

Different engines work quite differently, it is not useful to attempt to seed
them in a generic way using a 64 bit integer. As an example Mt19937 completely
ignores the upper 32 bits.

* random: Remove the `seed` member from `php_random_algo`

See the explanation in the previous commit for the reasoning. This member is
unused since the previous commit and was not consistently available even before
that (specifically for the Secure engine).

* UPGRADING.INTERNALS

* random: Remove useless cast in `php_mt_srand()`
* PHP-8.3:
  random: Fix unknown `mt_srand()` compatibility for unknown modes (php#13544)
  Merge branch 'PHP-8.2' into PHP-8.3
  Removed `REPORT_EXIT_STATUS=no` in libmysql tests
  Revert "Fix phpGH-13519: PGSQL_CONNECT_FORCE_RENEW with persistent connections." (php#13546)
* PHP-8.3:
  [ci skip] Fix version for phpGH-13544 in NEWS
This prepends -lnetwork as needed (Haiku) whether linker sees the
setsockopt function and avoids defining redundant symbols, such as
HAVE_LIBNETWORK and HAVE_SETSOCKOPT.
This moves memfd_create (HAVE_MEMFD_CREATE) to configure.ac. Since
ext/pcre is always enabled and check can be done in this case for
ext/pcre and ext/opcache at once.
* PHP-8.3:
  Fix phpGH-11808: Live filesystem modified by tests (security)
The FFI_* calling conventions are enum constants and AC_CHECK_DECL(S)
can be used to check for their existence in the ffi.h header. This
simplifes the checks and adds a simple AC_CHECK_DECL macro wrapper which
defines the HAVE_FFI_* belonging symbols.
The previous ordering resulted in a needlessly large number of holes and split
several `zval`s across cache line boundaries. Do the bare minimum of reordering
to keep related members grouped, but reducing the struct size by 32 bytes and
keeping `zval`s within a single cache line.

Before:

    struct _php_session_rfc1867_progress {
            size_t                     sname_len;            /*     0     8 */
            zval                       sid;                  /*     8    16 */
            smart_str                  key;                  /*    24    16 */
            zend_long                  update_step;          /*    40     8 */
            zend_long                  next_update;          /*    48     8 */
            double                     next_update_time;     /*    56     8 */
            /* --- cacheline 1 boundary (64 bytes) --- */
            _Bool                      cancel_upload;        /*    64     1 */
            _Bool                      apply_trans_sid;      /*    65     1 */

            /* XXX 6 bytes hole, try to pack */

            size_t                     content_length;       /*    72     8 */
            zval                       data;                 /*    80    16 */
            zval *                     post_bytes_processed; /*    96     8 */
            zval                       files;                /*   104    16 */
            zval                       current_file;         /*   120    16 */
            /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
            zval *                     current_file_bytes_processed; /*   136     8 */

            /* size: 144, cachelines: 3, members: 14 */
            /* sum members: 138, holes: 1, sum holes: 6 */
            /* last cacheline: 16 bytes */
    };
    struct _php_ps_globals {
            char *                     save_path;            /*     0     8 */
            char *                     session_name;         /*     8     8 */
            zend_string *              id;                   /*    16     8 */
            char *                     extern_referer_chk;   /*    24     8 */
            char *                     cache_limiter;        /*    32     8 */
            zend_long                  cookie_lifetime;      /*    40     8 */
            char *                     cookie_path;          /*    48     8 */
            char *                     cookie_domain;        /*    56     8 */
            /* --- cacheline 1 boundary (64 bytes) --- */
            _Bool                      cookie_secure;        /*    64     1 */
            _Bool                      cookie_httponly;      /*    65     1 */

            /* XXX 6 bytes hole, try to pack */

            char *                     cookie_samesite;      /*    72     8 */
            const ps_module  *         mod;                  /*    80     8 */
            const ps_module  *         default_mod;          /*    88     8 */
            void *                     mod_data;             /*    96     8 */
            php_session_status         session_status;       /*   104     4 */

            /* XXX 4 bytes hole, try to pack */

            zend_string *              session_started_filename; /*   112     8 */
            uint32_t                   session_started_lineno; /*   120     4 */

            /* XXX 4 bytes hole, try to pack */

            /* --- cacheline 2 boundary (128 bytes) --- */
            zend_long                  gc_probability;       /*   128     8 */
            zend_long                  gc_divisor;           /*   136     8 */
            zend_long                  gc_maxlifetime;       /*   144     8 */
            int                        module_number;        /*   152     4 */

            /* XXX 4 bytes hole, try to pack */

            zend_long                  cache_expire;         /*   160     8 */
            struct {
                    zval               ps_open;              /*   168    16 */
                    zval               ps_close;             /*   184    16 */
                    /* --- cacheline 3 boundary (192 bytes) was 8 bytes ago --- */
                    zval               ps_read;              /*   200    16 */
                    zval               ps_write;             /*   216    16 */
                    zval               ps_destroy;           /*   232    16 */
                    zval               ps_gc;                /*   248    16 */
                    /* --- cacheline 4 boundary (256 bytes) was 8 bytes ago --- */
                    zval               ps_create_sid;        /*   264    16 */
                    zval               ps_validate_sid;      /*   280    16 */
                    zval               ps_update_timestamp;  /*   296    16 */
            } mod_user_names;                                /*   168   144 */
            _Bool                      mod_user_implemented; /*   312     1 */
            _Bool                      mod_user_is_open;     /*   313     1 */

            /* XXX 6 bytes hole, try to pack */

            /* --- cacheline 5 boundary (320 bytes) --- */
            zend_string *              mod_user_class_name;  /*   320     8 */
            const struct ps_serializer_struct  * serializer; /*   328     8 */
            zval                       http_session_vars;    /*   336    16 */
            _Bool                      auto_start;           /*   352     1 */
            _Bool                      use_cookies;          /*   353     1 */
            _Bool                      use_only_cookies;     /*   354     1 */
            _Bool                      use_trans_sid;        /*   355     1 */

            /* XXX 4 bytes hole, try to pack */

            zend_long                  sid_length;           /*   360     8 */
            zend_long                  sid_bits_per_character; /*   368     8 */
            _Bool                      send_cookie;          /*   376     1 */
            _Bool                      define_sid;           /*   377     1 */

            /* XXX 6 bytes hole, try to pack */

            /* --- cacheline 6 boundary (384 bytes) --- */
            php_session_rfc1867_progress * rfc1867_progress; /*   384     8 */
            _Bool                      rfc1867_enabled;      /*   392     1 */
            _Bool                      rfc1867_cleanup;      /*   393     1 */

            /* XXX 6 bytes hole, try to pack */

            char *                     rfc1867_prefix;       /*   400     8 */
            char *                     rfc1867_name;         /*   408     8 */
            zend_long                  rfc1867_freq;         /*   416     8 */
            double                     rfc1867_min_freq;     /*   424     8 */
            _Bool                      use_strict_mode;      /*   432     1 */
            _Bool                      lazy_write;           /*   433     1 */
            _Bool                      in_save_handler;      /*   434     1 */
            _Bool                      set_handler;          /*   435     1 */

            /* XXX 4 bytes hole, try to pack */

            zend_string *              session_vars;         /*   440     8 */

            /* size: 448, cachelines: 7, members: 48 */
            /* sum members: 404, holes: 9, sum holes: 44 */
    };

After:

    struct _php_session_rfc1867_progress {
            size_t                     sname_len;            /*     0     8 */
            zval                       sid;                  /*     8    16 */
            smart_str                  key;                  /*    24    16 */
            zend_long                  update_step;          /*    40     8 */
            zend_long                  next_update;          /*    48     8 */
            double                     next_update_time;     /*    56     8 */
            /* --- cacheline 1 boundary (64 bytes) --- */
            _Bool                      cancel_upload;        /*    64     1 */
            _Bool                      apply_trans_sid;      /*    65     1 */

            /* XXX 6 bytes hole, try to pack */

            size_t                     content_length;       /*    72     8 */
            zval                       data;                 /*    80    16 */
            zval                       files;                /*    96    16 */
            zval *                     post_bytes_processed; /*   112     8 */
            zval *                     current_file_bytes_processed; /*   120     8 */
            /* --- cacheline 2 boundary (128 bytes) --- */
            zval                       current_file;         /*   128    16 */

            /* size: 144, cachelines: 3, members: 14 */
            /* sum members: 138, holes: 1, sum holes: 6 */
            /* last cacheline: 16 bytes */
    };
    struct _php_ps_globals {
            char *                     save_path;            /*     0     8 */
            char *                     session_name;         /*     8     8 */
            zend_string *              id;                   /*    16     8 */
            char *                     extern_referer_chk;   /*    24     8 */
            char *                     cache_limiter;        /*    32     8 */
            zend_long                  cookie_lifetime;      /*    40     8 */
            char *                     cookie_path;          /*    48     8 */
            char *                     cookie_domain;        /*    56     8 */
            /* --- cacheline 1 boundary (64 bytes) --- */
            char *                     cookie_samesite;      /*    64     8 */
            _Bool                      cookie_secure;        /*    72     1 */
            _Bool                      cookie_httponly;      /*    73     1 */

            /* XXX 6 bytes hole, try to pack */

            const ps_module  *         mod;                  /*    80     8 */
            const ps_module  *         default_mod;          /*    88     8 */
            void *                     mod_data;             /*    96     8 */
            php_session_status         session_status;       /*   104     4 */

            /* XXX 4 bytes hole, try to pack */

            zend_string *              session_started_filename; /*   112     8 */
            uint32_t                   session_started_lineno; /*   120     4 */
            int                        module_number;        /*   124     4 */
            /* --- cacheline 2 boundary (128 bytes) --- */
            zend_long                  gc_probability;       /*   128     8 */
            zend_long                  gc_divisor;           /*   136     8 */
            zend_long                  gc_maxlifetime;       /*   144     8 */
            zend_long                  cache_expire;         /*   152     8 */
            struct {
                    zval               ps_open;              /*   160    16 */
                    zval               ps_close;             /*   176    16 */
                    /* --- cacheline 3 boundary (192 bytes) --- */
                    zval               ps_read;              /*   192    16 */
                    zval               ps_write;             /*   208    16 */
                    zval               ps_destroy;           /*   224    16 */
                    zval               ps_gc;                /*   240    16 */
                    /* --- cacheline 4 boundary (256 bytes) --- */
                    zval               ps_create_sid;        /*   256    16 */
                    zval               ps_validate_sid;      /*   272    16 */
                    zval               ps_update_timestamp;  /*   288    16 */
            } mod_user_names;                                /*   160   144 */
            zend_string *              mod_user_class_name;  /*   304     8 */
            _Bool                      mod_user_implemented; /*   312     1 */
            _Bool                      mod_user_is_open;     /*   313     1 */
            _Bool                      auto_start;           /*   314     1 */
            _Bool                      use_cookies;          /*   315     1 */
            _Bool                      use_only_cookies;     /*   316     1 */
            _Bool                      use_trans_sid;        /*   317     1 */
            _Bool                      send_cookie;          /*   318     1 */
            _Bool                      define_sid;           /*   319     1 */
            /* --- cacheline 5 boundary (320 bytes) --- */
            const struct ps_serializer_struct  * serializer; /*   320     8 */
            zval                       http_session_vars;    /*   328    16 */
            zend_long                  sid_length;           /*   344     8 */
            zend_long                  sid_bits_per_character; /*   352     8 */
            php_session_rfc1867_progress * rfc1867_progress; /*   360     8 */
            char *                     rfc1867_prefix;       /*   368     8 */
            char *                     rfc1867_name;         /*   376     8 */
            /* --- cacheline 6 boundary (384 bytes) --- */
            zend_long                  rfc1867_freq;         /*   384     8 */
            double                     rfc1867_min_freq;     /*   392     8 */
            _Bool                      rfc1867_enabled;      /*   400     1 */
            _Bool                      rfc1867_cleanup;      /*   401     1 */
            _Bool                      use_strict_mode;      /*   402     1 */
            _Bool                      lazy_write;           /*   403     1 */
            _Bool                      in_save_handler;      /*   404     1 */
            _Bool                      set_handler;          /*   405     1 */

            /* XXX 2 bytes hole, try to pack */

            zend_string *              session_vars;         /*   408     8 */

            /* size: 416, cachelines: 7, members: 48 */
            /* sum members: 404, holes: 3, sum holes: 12 */
            /* last cacheline: 32 bytes */
    };
ranvis and others added 27 commits March 27, 2024 09:06
This adds all root build directories in one call. PEAR directory is
created only when enabled and duplicated Zend directory creation is
removed, because it was intended for the zend_config.h when building
out-of-source or using the config.status manually before the
PHP_ADD_BUILD_DIR was introduced in the build system.
Useful to control how many SYN packets the client will send to the
server before giving up establishing a connection if the server does
not respond (usually 5 or 6 by default).

Close phpGH-13816
* PHP-8.3:
  Fix phpGH-13827: Null pointer access of type 'zval' in phpdbg_frame
The POSIX shared memory object operations functions (shm_open,
shm_unlink...) are in:
* C library on most systems (newer Linux, Solaris 11.4, illumos, BSD*,
  macOS, Haiku, etc.)
* real-time (rt) library on older Linux distributions and Solaris <= 10.

Haiku C library (called root library) on Haiku is linked in by default.

Previous check always added additional rt or root library to global LIBS
and rt to OPCACHE_SHARED_LIBADD. Now, the library containing shm_open is
linked as needed to the always shared opcache extension.

This also removes unused HAVE_SHM_OPEN and HAVE_LIBROOT symbols.
* PHP-8.3:
  Fix phpGH-13836: Renaming a file in a Phar to an already existing filename causes a NULL pointer dereference
* PHP-8.3:
  Fix phpGH-13833: Applying zero offset to null pointer in zend_hash.c
`dbh` is always non-NULL because it is dereferenced at the start of the
function.
result is always non-NULL because it is dereferenced above.
Similarly, result->unbuf and stmt must also be non-NULL.
`conn` is dereferenced at top so it is always non-NULL.
* PHP-8.3:
  Skip test on Windows because of different error output
…nge maxDepth (php#13731)

There are two depth limiting parameters for XSLT templates.
1) maxTemplateDepth
   This corresponds to the recursion depth of a template. For very
   complicated templates this can be hit.
2) maxTemplateVars
   This is the total number of live variables. When using recursive
   templates with lots of parameters you can hit this limit.

This patch introduces two new properties to XSLTProcessor that
corresponds to the above variables.
`old_root` is dereferenced at top, so `old_root` must not be NULL, and
the check doesn't actually do anything.
…jit.c (php#13846)

* Fix phpGH-13834: Applying non-zero offset 36 to null pointer in zend_jit.c

ssa_op can be NULL in function JIT. Doing pointer arithmetic on a NULL
pointer is undefined behaviour. Undefined behaviour can be dangerous
because the optimizer may assume then that the variable is not actually
NULL.

To solve this:
1. Add ADVANCE_SSA_OP() to safely add an offset to ssa_op in zend_jit.c
2. For inference, add an extra offset argument to the helper functions.

To reproduce this, use Clang (not GCC) on a test like
sapi/cli/tests/gh12363.phpt (or other tests also work).

* Remove -fno-sanitize=pointer-overflow flag from CI

* Fix NULL pointer offsets added to the stack_map

* Fix an offset add on a potentially NULL ssa->ops

* Fix NULL pointer arithmetic in zend_range_info()

* Address review comments
Copy link

@derickr derickr left a comment

Choose a reason for hiding this comment

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

LGTM

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.