History log of /php-src/Zend/zend.c (Results 1 – 25 of 889)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 9bbc195d 23-Apr-2024 Arnaud Le Blanc

Remove zend_strtod mutex (#13974)

`zend_strtod.c` uses a global state (mostly an allocation freelist) protected by a mutex in ZTS builds. This state is used by `zend_dtoa()`, `zend_strtod()`

Remove zend_strtod mutex (#13974)

`zend_strtod.c` uses a global state (mostly an allocation freelist) protected by a mutex in ZTS builds. This state is used by `zend_dtoa()`, `zend_strtod()`, and variants. This creates a lot of contention in concurrent loads. `zend_dtoa()` is used to format floats to string, e.g. in sprintf, json_encode, serialize, uniqid.

Here I move the global state to the thread specific `executor_globals` and remove the mutex.

The impact on non-concurrent environments is null or negligible, but there is a considerable speed up on concurrent environments, especially on Alpine/Musl.

show more ...


# 3301d960 12-Mar-2024 Ilija Tovilo

Restore error handler after running it

Symfony relies on finding the exception handler in the handler stack. There's
currently no clean API to find it, so they pop all the handlers, and

Restore error handler after running it

Symfony relies on finding the exception handler in the handler stack. There's
currently no clean API to find it, so they pop all the handlers, and push them
again once the stack is empty. This PR attempts to minimize the BC break by
pushing the current handler onto the stack and clearing the current handler, and
restoring it once it has finished. This is essentially equivalent to
set_exception_handler(null) and restore_exception_handler().

restore_exception_handler() however is only called if the exception handler is
still unset. If the handler has pushed a new handler in the meantime, we assume
it knows what it's doing.

Fixes GH-13446
Closes GH-13686

show more ...


# 2f605820 13-Feb-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Workaround ZTS persistent resource crashes (PHP 8.3 and lower)

For master (8.4-dev) I merged GH-13381. But that PR changes public API
of TSRM, so cannot be used on lower branches.

Workaround ZTS persistent resource crashes (PHP 8.3 and lower)

For master (8.4-dev) I merged GH-13381. But that PR changes public API
of TSRM, so cannot be used on lower branches.

This patch is a safe workaround for the issue, in combination with a
pre-existing fix using `ifdef ZTS + if (module_started)` inside pgsql
and odbc. The idea is to delay unloading modules until the persistent
resources are destroyed. This will keep the destructor code accessible
in memory.

This is not a proper fix on its own, because we still need the
workaround of not accessing globals after module destruction.
The proper fix is in master.

Closes GH-13388.

show more ...


# 5941cdaa 13-Feb-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix ZTS crashes with persistent resources in modules (#13381)

On shutdown in ZTS the following happens:
- https://github.com/php/php-src/blob/master/Zend/zend.c#L1124-L1125
gets ex

Fix ZTS crashes with persistent resources in modules (#13381)

On shutdown in ZTS the following happens:
- https://github.com/php/php-src/blob/master/Zend/zend.c#L1124-L1125
gets executed. This destroys global persistent resources and destroys
the modules. Furthermore, the modules are unloaded too.
- Further down, `ts_free_id(executor_globals_id)` gets executed, which
calls `executor_globals_dtor`. This function destroys persistent
resources for each thread.

Notice that in the last step, the modules that the persistent resource
belong to may already have been destroyed. This means that accessing
globals will cause a crash (I previously fixed this with ifdef magic),
or when the module is dynamically loaded we'll try jumping to a
destructor that is no longer loaded in memory. These scenarios cause
crashes.

It's not possible to move the `ts_free_id` call upwards, because that
may break assumptions of callers, and furthermore this would deallocate
the executor globals structure, which means that any access to those
will cause a segfault.

This patch adds a new API to the TSRM that allows running a callback on
a certain resource type. We use this API to destroy the persistent
resources in all threads prior to the module destruction, and keep the
rest of the resource dtor intact.

I verified this fix on Apache with postgres, both dynamically and
statically.

Fixes GH-12974.

show more ...


# c149b4f5 30-Jan-2024 Ilija Tovilo

Fix missing syntax error message in cli-server router script

Fixes GH-13113
Closes GH-13275


# 631bc816 06-Feb-2024 Ilija Tovilo

Implement stackless internal function calls

Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12461


# fe064d7f 19-Jan-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix GH-13142: Undefined variable name is shortened when contains \0

Uses the new %S formatter and introduces the necessary changes and
helpers.


# fe3a819e 01-Nov-2023 Dmitry Stogov

Fixed GH-12564: The negative fiber.stack_size setting leads to crash


# 692cea5c 13-Sep-2023 Ilija Tovilo

Use zend_error_noreturn for E_ERROR consistently

To be clear, these already don't return. zend_error_noreturn just hints at this
fact through the ZEND_NORETURN attribute.

Closes

Use zend_error_noreturn for E_ERROR consistently

To be clear, these already don't return. zend_error_noreturn just hints at this
fact through the ZEND_NORETURN attribute.

Closes GH-12204

show more ...


# 53aa53f4 24-Aug-2023 Jakub Zelenka

Introduce Zend guard recursion protection

This PR introduces a new way of recursion protection in JSON, var_dump
and friends. It fixes issue in master for __debugInfo and also improves

Introduce Zend guard recursion protection

This PR introduces a new way of recursion protection in JSON, var_dump
and friends. It fixes issue in master for __debugInfo and also improves
perf for jsonSerializable in some cases. More info can be found in
GH-10020.

Closes GH-11812

show more ...


# 96885bc0 05-Aug-2023 Kévin Dunglas

fix: handle the GNU specific version of strerror_r

Close GH-11882


# 127ad707 24-Jul-2023 Ilija Tovilo

Fix open_basedir leak

Fixes oss-fuzz #60741
Closes GH-11780


# 9bcdf219 31-Mar-2023 Ilija Tovilo

Resolve open_basedir paths on ini update

Closes GH-10987


# d0731934 16-Jul-2023 Arnaud Le Blanc

Expose time spent collecting cycles in gc_status() (#11523)


# b3e33be4 21-Mar-2023 Ilija Tovilo

Forward shutdown exceptions to user error handlers

Fixes GH-10695
Closes GH-110905


# 99fa740a 06-Jun-2023 George Peter Banyard

Use common function for TypeError on illegal offset access (#10544)

This merges all usages of emitting an offset TypeError into a new ZEND_API function
zend_illegal_container_offset(cons

Use common function for TypeError on illegal offset access (#10544)

This merges all usages of emitting an offset TypeError into a new ZEND_API function
zend_illegal_container_offset(const zend_string* container, const zval *offset, int type);

Where the container should represent the type on which the access is attempted (e.g. string, array)
The offset zval that is used, where the error message will display its type
The type of access, which should be a BP_VAR_* constant, to get special message for isset/empty/unset

show more ...


# 4c38a79f 20-Apr-2023 Ilija Tovilo

Fix incorrect CG(memoize_mode) state after bailout in ??=

Fixes GH-11108
Closes GH-11109


# c9d728cb 04-Apr-2023 Dmitry Stogov

Revert "Zend/zend_types.h: move `zend_rc_debug` to `zend_rc_debug.h`"

This reverts commit d6e95041e291f1f41e1da43e616c6354705464d3.


# 6f1e5ff8 10-Mar-2023 Ilija Tovilo

Fix GC_BENCH flag (#10823)

zend_gc_globals is now hidden, so we can't access it from zend.c.


# ff62d117 04-Mar-2023 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix GH-8646: Memory leak PHP FPM 8.1

Fixes GH-8646
See https://github.com/php/php-src/issues/8646 for thorough discussion.

Interned strings that hold class entries can get a cor

Fix GH-8646: Memory leak PHP FPM 8.1

Fixes GH-8646
See https://github.com/php/php-src/issues/8646 for thorough discussion.

Interned strings that hold class entries can get a corresponding slot in map_ptr for the CE cache.
map_ptr works like a bump allocator: there is a counter which increases to allocate the next slot in the map.

For class name strings in non-opcache we have:
- on startup: permanent + interned
- on request: interned
For class name strings in opcache we have:
- on startup: permanent + interned
- on request: either not interned at all, which we can ignore because they won't get a CE cache entry
or they were already permanent + interned
or we get a new permanent + interned string in the opcache persistence code

Notice that the map_ptr layout always has the permanent strings first, and the request strings after.
In non-opcache, a request string may get a slot in map_ptr, and that interned request string
gets destroyed at the end of the request. The corresponding map_ptr slot can thereafter never be used again.
This causes map_ptr to keep reallocating to larger and larger sizes.

We solve it as follows:
We can check whether we had any interned request strings, which only happens in non-opcache.
If we have any, we reset map_ptr to the last permanent string.
We can't lose any permanent strings because of map_ptr's layout.

Closes GH-10783.

show more ...


# ad85e714 03-Mar-2023 Kévin Dunglas

fix: support for timeouts with ZTS on Linux (#10141)


# d6e95041 13-Jan-2023 Max Kellermann

Zend/zend_types.h: move `zend_rc_debug` to `zend_rc_debug.h`

`zend_rc_debug` is not a type and does not really belong in
`zend_types.h`; this allows using `ZEND_RC_MOD_CHECK()` without

Zend/zend_types.h: move `zend_rc_debug` to `zend_rc_debug.h`

`zend_rc_debug` is not a type and does not really belong in
`zend_types.h`; this allows using `ZEND_RC_MOD_CHECK()` without
including the huge `zend_types.h` header and allows decoupling
circular header dependencies.

show more ...


# bf036fa2 18-Feb-2023 Max Kellermann

Zend/zend_globals: convert fiber_stack_size to `size_t` (#10619)

`zend_long` is a signed integer that's only 32 bit on some 64 bit
architectures (e.g. ARM64). The proper type for memory

Zend/zend_globals: convert fiber_stack_size to `size_t` (#10619)

`zend_long` is a signed integer that's only 32 bit on some 64 bit
architectures (e.g. ARM64). The proper type for memory sizes is
`size_t`, and this type is accepted by zend_fiber_init_context().

show more ...


# 3b75f07c 13-Feb-2023 Dmitry Stogov

Stop copying internal functions into each thread (#10517)

* Stop copying internal functions into each thread

It seems we don't copy internal methods for a long time, so this
sho

Stop copying internal functions into each thread (#10517)

* Stop copying internal functions into each thread

It seems we don't copy internal methods for a long time, so this
shouldn't be a problem. We had to copy functions in PHP-5 times, but it
seems we just forgot to remove this.

It's possible that some third-part extensions (e.g. profilers, tracers,
debuggers) modify internal functions. After this change that may cause
race conditions in ZTS build (but we already jave the same behavior for
internal methods). Observer API should provide necesssary functionality
to avoid shared structures modification.

* Remove unused function

show more ...


# c8955c07 16-Jan-2023 Christoph M. Becker

Revert GH-10220

Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491d66081298a16634629f149459706a9.
This reverts commit 588a07

Revert GH-10220

Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491d66081298a16634629f149459706a9.
This reverts commit 588a07f7371ee2b5fac17de147926780e427fae6.
This reverts commit f377e15751d3aa48b69cd9bcc366ede7803d511f.
This reverts commit b4ba16fe189b109144aff669e11d81365160104b.
This reverts commit 694ec1deea36e366b28b6349a52be49824e1a1a8.
This reverts commit 6b34de8eba9f66882ae16e6073af28783670ac53.
This reverts commit aa1cd02a4367834026ea2205ea13a2f904455aa1.
This reverts commit 308fd311ea6fcf3094b448df7f2b264f08e4fe4f.
This reverts commit 16203b53e1822a37b6ba6f2ab198bb435d05fdad.
This reverts commit 738fb5ca5412f5e833a7fab82b11519e635a3357.
This reverts commit 9fdbefacd3c382d731aa175b7bdc002ec9cb2b30.
This reverts commit cd4a7c1d90562ebb5f89caf94d00d579631b9fbe.
This reverts commit 928685eba2b2f0ded90e7f78fd806ea164002f6e.
This reverts commit 01e5ffc85cd4357fd7b5b7ceefa29f2d10ca26b7.

show more ...


12345678910>>...36