This effectively inlines the behaviour of php_mkdir_ex() which is a deprecated API from at least 17 years ago, and also fixes some of the return values.
This also removes a dependency on ext/standard
There are two related issues, each tested.
First problem:
What happens is that on the CLI SAPI we have a per-request pcre cache,
and on there the request shutdown for the pcre module happens prior to
the remaining live object destruction. So when the SPL object wants to
clean up the regular expression object it gets a use-after-free.
Second problem:
Very similarly, the non-persistent resources are destroyed after request
shutdown, so on the CLI SAPI the pcre request cache is already gone, but
if a userspace stream references a regex in the pcre cache, this breaks.
Two things that come immediately to mind:
- We could fix it by no longer treating the CLI SAPI special and just use
the same lifecycle as the module. This simplifies the pcre module code
a bit too. I wonder why we even have the separation in the first place.
The downside here is that we're using more the system allocator
than Zend's allocator for cache entries.
- We could modify the shutdown code to not remove regular expressions
with a refcount>0 and modify php_pcre_pce_decref code such that it
becomes php_pcre_pce_decref's job to clean up when the refcount
becomes 0 during shutdown. However, this gets nasty quickly.
I chose the first solution here as it should be reliable and simple.
Closes GH-15064.
The PHP_BUILD_THREAD_SAFE macro is a simple wrapper around setting the
enable_zts variable and can't be used in PHP extensions realistically.
The PHP_TEST_BUILD macro might produce warnings on certain compiler
configurations and default AC_* macros like AC_LINK_IFELSE,
AC_CHECK_LIB, or AC_CHECK_FUNC are better suited for such checks. Also,
a quick browse through the open-source PHP extensions doesn't find
usages of this macro except in imap extension where patch is was already
sent:
https://github.com/php/pecl-mail-imap/pull/11
PHP_DEF_HAVE is a wrapper around AC_DEFINE and using AC_DEFINE_UNQUOTED
and AS_TR_CPP are better suited for this task where also help text can
be passed. Usages in the open source PHP extensions have been checked and
patches sent where found.
The apxs -q HTTPD_VERSION variable is available since Apache 2.4.17.
This change obsoletes the PHP_AP_EXTRACT_VERSION macro and checks the
version in the config.m4 file directly. Version is checked against the
dotted format instead of the version number.
This enables adding multiple include paths. For example:
PHP_ADD_INCLUDE([
$abs_srcdir
$abs_builddir
$abs_srcdir/main
$abs_builddir/main
], [1])
The 2nd argument "prepend" is now validated at Autoconf compile time
instead of the configure time.
M4 macros would mean macros for M4 language like m4_normalize() and
similar. Macros defined with AC_DEFUN are better called simply Auotoconf
macros.
[skip ci]
* Check VM interrupt while internal frame is on top
* Use tab instead of spaces
* fix frame used in interrupt and refactor
* remove unused failures for zend_jit_check_timeout
* Fix JIT support
Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
* Fix the missing store to vm_interrupt
* Rename new functions
* Special case zend_interrupt_function in JIT code
* refactor to use ZEND_VM_SET_OPCODE_NO_INTERRUPT
* Split atomic exchange into load + store
It is difficult to determine performance of atomics sometimes. In this
case, the separate load+store is still correct, and a load does not
cause a modification, and might be faster for some platforms than an
exchange. A load+store is slower than an exchange, but we're fine
trading the penalty to the slow path and keeping the happy path faster.
---------
Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
This is a follow up of 7edb9a07d7 that
provides passing compilation options to PHP_NEW_EXTENSION,
PHP_ADD_SOURCES, PHP_ADD_SOURCES_X, and PHP_SELECT_SAPI as a
blank-or-newline-separated argument.
By using `m4_normalize(m4_expand([...]))`, the arguments can be split
into newlines without using backslashes and it makes working with lists
of files a bit easier.
Tested:
- variables inside the argument
- M4 macro expansions
- dnl comments
- any sequence of newlines, backslash-then-newline, multiple spaces,
tabs...
- quoted/unquoted arguments
This now works for PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X,
and PHP_SELECT_SAPI. The m4_normalize() usage is left in the php-src
config.m4 files following the 0a0d2d0631
for PECL extensions until phpize will be available on all supported
versions (minimum PHP 8.4).
The m4_normalize(m4_expand([$1])) expands the given argument if it
contains M4 macros, and then trims the items together into a space
separated string in an intuitive way.
The m4_normalize(m4_expand([...])) simplifies working with a list of
header files. The m4_normalize() is at this point still used in the
php-src config.m4 files because of copy/paste probability to community
extensions where the arguments still need to be done in the old style to
support phpize in PHP-8.3 and earlier. For example:
PHP_INSTALL_HEADERS([ext/dom], m4_normalize([
dom_ce.h
namespace_compat.h
xml_common.h
xpath_callbacks.h
]))
When PHP 8.4 will be the minimum supported PHP version, the headers can
be installed without using m4_normalize() in PECL extensions. For
example:
PHP_INSTALL_HEADERS([ext/dom], [
dom_ce.h
namespace_compat.h
xml_common.h
xpath_callbacks.h
])
The xmlDictPtr was moved before the includes in libxml2 2.9.4 so the
<libxml/dict.h> can be included directly but for earlier versions the
<libxml/tree.h> needs to be included before. Since PHP requires libxml2
2.9.0 or later and this also fixes builds on Solaris 10.
As earlier 2.9.0-2.9.3 libxml2 versions also include several security
issues, this change bumps the required minimum libxml2 version to 2.9.4
On Windows, a check for minimum libxml2 version is also added.
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
This makes a bit simpler to use this macro by optionally passing the
required minimum PHP version. If version is not passed it falls back
to 7.4 as before. Minimum version also added to configure.ac.
Previously the CHECK_HEADER_ADD_INCLUDE function defined the
`HAVE_<header>_H` preprocessor macros to value 0 or 1 whether the
`<header.h>` file was found. This syncs it with Autotools build system
where most of these macros are either undefined or defined to 1.
In possible edge cases where such macros might be intentionally used
like this without being aware that HAVE_HEADER_H can be 0 or 1 on
Windows:
| #ifdef HAVE_HEADER_H
| ...
| #endif
there is backwards incompatibility for PECL extensions in case the
header wouldn't exist on Windows such code wouldn't execute. However,
this is considered a bug if such case is present. From the Autotools
point of view, the check is correct though and should be used with
ifdef/defined() checks.
Help text is also synced to Autotools style:
`Define to 1 if you have the <header.h> header file.`
YIELD and YIELD_FROM increment opline before returning, but in most places
we need the opline to point to the YIELD and YIELD_FROM.
Here I change YIELD / YIELD_FROM to not increment opline. This simplifies the
code and fixes GH-15275 in a better way.
Closes GH-15328
NET-SNMP has pkg-config support since 5.8.1
This optionally finds the NET-SNMP library using pkg-config or falls
back to find library on the system with net-snmp-config. The configure
option argument (--with-snmp=DIR) works like before (path to the
net-snmp-config).
When explicitly using the DIR argument, the pkg-config check is silently
skipped.
When not using DIR argument, the SNMP_CFLAGS and SNMP_LIBS can be also
used to find the NET-SNMP library:
./configure --with-snmp \
SNMP_CFLAGS=-I/path/to/net-snmp/include \
SNMP_LIBS="-L/path/to/net-snmp -lnetsnmp"
Co-authored-by: Calvin Buckley <calvin@cmpct.info>
From the documentation[1]:
| We're updating the Microsoft C++ preprocessor to improve standards
| conformance, fix longstanding bugs, and change some behaviors that
| are officially undefined. We've also added new diagnostics to warn
| on errors in macro definitions.
Thus it appears to be sensible to switch to the new preprocessor for
all VS17 builds. Note that although the new preprocessor is available
as of VS16.5 (i.e. `version >= 1925`), we don't want to potentially
break older builds, and as such use the new preprocessor only for VS17
builds. Users who wish to use the new preprocessor with VS16, can
still `set CFLAGS=/Zc:preprocessor` before running `buildconf`/`phpize`.
[1] <https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170>
Closes GH-15201.
GMP has pkg-config integration since 2019-08-22 (version ~6.2.0).
This optionally finds the GMP library using pkg-config or falls back to
find library on the system or with the provided configure option
argument (--with-gmp=DIR).
When using DIR argument, the pkg-config check is silently skipped.
When not using DIR argument, the GMP_CFLAGS and GMP_LIBS can be also
used to find the GMP library:
./configure --with-gmp \
GMP_CFLAGS=-I/path/to/gmp/include \
GMP_LIBS="-L/path/to/gmp -lgmp"
This flag was never necessary. We know a static variable is uninitialized (i.e.
the initializer has never been called) iff the zval in the static variable array
does not contain a reference.
Prompted by a related issue in ext-uopz reported by Christoph.
This is a follow-up of GH-15177
(c96f08aa70)
and GH-15185
(9467ffb43c)
The PHP_OUTPUT macro was introduced in the very early phase of the build
system due to AC_OUTPUT handling issues in the old Autoconf versions
before the AC_CONFIG_FILES, AC_CONFIG_COMMANDS etc were introduced with
the AC_OUTPUT signature without arguments. The PHP_OUTPUT was also
helping Makefile.in back then being properly generated based on whether
all files were generated or only some (when using the obsolete
CONFIG_FILES=... ./config.status invocation instead of the new
./config.status --file=...). Another issue is that PHP_OUTPUT can't be
used by extensions when using phpize.
This replaces the PHP_OUTPUT invocations with default AC_CONFIG_FILES.
The obsolete "REDO_ALL" feature at the config.status invocation is also
removed with a simpler unconditional generation.
In phar extension the "ext/phar" is replaced with $ext_dir variable to
be able to use phpize.
- PHP_SETUP_LIBXML arguments quoted
- Help texts updated for HAVE_LIBXML, HAVE_DOM, HAVE_XMLREADER,
HAVE_XMLWRITER, HAVE_SOAP, HAVE_SIMPLEXML, and HAVE_XML CPP macros
- Duplicate HAVE_LIBXML symbol definition in PHP_SETUP_LIBXML M4 macro
removed (the HAVE_LIBXML marks that PHP libxml extension is available and
not only that libxml2 library is available)
This checks if crypt and crypt_r functions are available on the system
in default libraries or in the crypt library with the AC_SEARCH_LIBS.
The redundant HAVE_LIBCRYPT symbol is removed.
The zend_object.properties HashTable needs to be built just in time by calling
rebuild_object_properties() on the object before accessing it. Normally this is
done automatically in zend_std_get_properties(), but we do it manually in a few
places.
In this change I introduce an inline variant of zend_std_build_properties(), and
refactor these places to use it instead of calling rebuild_object_properties()
manually.
rebuild_object_properties() renamed as rebuild_object_properties_internal(), to
enforce usage of zend_std_get_properties() or zend_std_build_properties_ex().
Closes GH-14996
PHP_EVAL_LIBALINE macro processes the given libraries flags (-l) and/or
library paths flags (-L) and appends the -l flags to either LIBS or the
given *_SHARED_LIBADD variables. The -L flags are appended to the
LDFLAGS. The new 3rd argument enables appending libraries to the given
variable in the 2nd argument without manual setting whether the
extension is shared. For example, to simplify usage in SAPIs where
additional libraries need to be appended but they shouldn't go to the
global LIBS. This can be then used in PHP-FPM SAPI to link apparmor,
SELinux, systemd, etc.
This creates a single M4 macro PHP_CHECK_BUILTIN and removes other
PHP_CHECK_BUILTIN_* macros. Checks are wrapped in AC_CACHE_CHECK and
PHP_HAVE_BUILTIN_* CPP macro definitions are defined to 1 if builtin
is found and undefined if not.
This also changes all PHP_HAVE_BUILTIN_ symbols to be either undefined
or defined (to value 1) and syncs all #if/ifdef/defined usages of them
in the php-src code. This way it is simpler to use them because they
don't need to be defined to value 0 on Windows, for example. This is
done as previous usages in php-src were mixed and on many places they
were only checked with ifdef.
Apache 2.2 has been marked as EOL in December 2017 and doesn't receive
security patches any longer. Also, most *nix distributions and packages
mostly support 2.4 as minimum by now.
On Windows, this removes the configure option --enable-apache2-2handler
and merges the --enable-apache2handler and --enable-apache2-4handler
into a single option with favoring the --enable-apache2handler.
- The upstream MODULE_MAGIC_NUMBER is deprecated in favor of
MODULE_MAGIC_NUMBER_MAJOR in apache2/ap_mmn.h
- The initial upstream MODULE_MAGIC_NUMBER_MAJOR was 20111025 in Apache
2.4.0
- The upstream APLOG_USE_MODULE is always available since Apache 2.3.6
- The upstream CORE_PRIVATE is unnecessary and ignored since Apache
2.4.0
See:
https://forum.apachehaus.com/news-general-discussion/apache-2-2-users-your-time-is-running-out/
Discussion: https://news-web.php.net/php.internals/124067
The PTHREADS_CHECK is using cache variables so it is run only once early
during the configuration phase, before including SAPI and other M4
files. This removes the TSRM_CHECK_PTHREADS macro and moves the POSIX
Threads check after the PHP_THREAD_SAFETY variable is set in
configure.ac.
The check and error throw in PHP_BUILD_THREAD_SAFE is also joing into
this single check.
This removes the redundant tsrm.m4 file and PHP_CONFIGURE_PART call for
TSRM as it doesn't run any configuration checks anymore.
* Autotools: Refactor AVX-512 checks
- CS synced
- checks wrapped in AC_CACHE_CHECK
- CPP macros PHP_HAVE_AVX512_SUPPORTS and PHP_HAVE_AVX512_VBMI_SUPPORTS
are now either defined to 1 or undefined to avoid manual defining on
Windows (previously they should be either 0 or 1)
* [skip ci] Add basic macros help texts
The strptime, where available, needs the _GNU_SOURCE defined or compiler
flag -std=gnuXX appended to be declared in time.h. PHP's strptime is
also deprecated as of PHP 8.1.
This removes the HAVE_STRPTIME_DECL_FAILS in favor of a simpler
AC_CHECK_DECL check and HAVE_DECL_STRPTIME CPP macro.