Commit Graph

18939 Commits

Author SHA1 Message Date
Niels Dossche
700fbca58d
Change getThis() into ZEND_THIS where possible (#13641) 2024-03-08 22:19:06 +01:00
Niels Dossche
d6d3370034
Implement GH-13609: Dump wrapped object in WeakReference class (#13621)
I chose "object" as that's also the argument name in WeakReference::create.
2024-03-08 18:31:24 +01:00
Niels Dossche
e7888a46fa Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS
  Fix GH-13612: Corrupted memory in destructor with weak references
2024-03-08 18:27:19 +01:00
Niels Dossche
3fba242124 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS
  Fix GH-13612: Corrupted memory in destructor with weak references
2024-03-08 18:27:10 +01:00
Niels Dossche
39b8d5c871 Fix GH-13612: Corrupted memory in destructor with weak references
Inside `zend_object_std_dtor` the weakrefs are notified after the destruction
of properties already took place. In this test case, the destructor of an anon
class will be invoked due to the property destruction. That class has a
weak reference to its parent. This means that the destructor can access
parent properties that already have been destroyed, resulting in a UAF.
Fix this by notifying the weakrefs at the start of the object's
destruction.

Closes GH-13613.
2024-03-08 18:26:17 +01:00
Ilija Tovilo
6db06a7c0f
Fix class name in warning of frameless calls (#13619) 2024-03-07 20:11:27 +01:00
Cristian Rodríguez
013978e506
Zend/fibers: Ensure fiber stack is not backed by THP. (#13306)
Ending with fiber stack mapped in hugepages will affect performance
badly.
Until < Linux 6.8-rc2 MAP_STACK was a noop, now it implies no THP, older releases
need madvise.
2024-03-05 20:50:43 +01:00
Arnaud Le Blanc
48274030d3 Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip]
  Fix GH-13569: GC buffer unnecessarily grows up to GC_MAX_BUF_SIZE when scanning WeakMaps
2024-03-05 12:20:12 +01:00
Arnaud Le Blanc
6b57e2d988 Fix GH-13569: GC buffer unnecessarily grows up to GC_MAX_BUF_SIZE when scanning WeakMaps 2024-03-05 12:17:21 +01:00
David CARLIER
e3b6872b51
zend call stack adjust case for freebsd to calculate the guard size. (#13586)
it was not wrong but there is a sysctl oid storing the number of guard
pages, which is 1 by default but is modifiable at runtime.
2024-03-04 19:06:37 +00:00
Jakub Zelenka
47dca339a4
PHP-8.3 is now for PHP-8.3.5-dev 2024-02-28 11:46:49 +00:00
Sergey Panteleev
e1a8ebd61b
PHP-8.2 is now for PHP 8.2.18-dev 2024-02-27 17:26:44 +03:00
Florian Engelhardt
14873dd286
Drop zend_mm_set_custom_debug_handlers() (#13457)
Simplifies zend_mm_set_custom_debug_handlers to just use zend_mm_set_custom_handlers(), saving some conditionals when the Zend allocator is not used.
2024-02-26 14:04:33 +01:00
Gina Peter Banyard
295a177760
Zend/tests/offsets: Add tests where the offset is a reference (#13506) 2024-02-26 03:36:35 +00:00
Gina Peter Banyard
1256d745c6
Zend/tests/offsets: add tests for taking references (#13496) 2024-02-25 15:22:59 +00:00
Máté Kocsis
f2e199e878
Implement "support doc comments for internal classes and functions" (#13266)
Fixes #13130
2024-02-25 08:41:31 +01:00
Peter Kokot
ec778c0dd7 Use default HAVE_SIGSETJMP symbol description
When AC_DEFINE is called after some macro that has already defined the
symbol with description (help text), it can be called with two arguments
to make things easier.

[ci skip]
2024-02-24 20:46:34 +01:00
Appla
ef61ed10c2
Remove redundant getpid function call (#13454) 2024-02-21 15:33:15 +01:00
Jorg Adam Sowa
e630aacf79
Remove HAVE_INET_PTON (#13410) 2024-02-21 00:43:56 +00:00
Niels Dossche
6c735739f1 Merge branch 'PHP-8.3'
* PHP-8.3:
  Workaround ZTS persistent resource crashes (PHP 8.3 and lower)
2024-02-20 21:26:39 +01:00
Niels Dossche
3ab7aa001f Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Workaround ZTS persistent resource crashes (PHP 8.3 and lower)
2024-02-20 21:25:06 +01:00
Niels Dossche
2f605820a4 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.
2024-02-20 21:24:43 +01:00
Arnaud Le Blanc
3baa606f58 Specify what is expected in zend_call_stack.base 2024-02-20 15:34:44 +01:00
Gina Peter Banyard
a45048b983
Zend/tests/offsets: Add test for fetching reference of an object container 2024-02-19 12:26:44 +00:00
Peter Kokot
51050427f4
Remove obsolescent AC_C_INLINE Autoconf macro (#13429)
This macro defines the inline keyword to be `__inline__`, `__inline`,
or empty, based on the compiler inline support. Since PHP requires C99,
which has the inline keyword definition and all current compilers
support it, this check is redundant and not needed anymore.
2024-02-18 23:55:50 +00:00
Máté Kocsis
10957e498c
Do not generate frameless info items when func info generation is disabled
While here, I fixed newlines around arginfo and function entry generation. Previously, newlines were repeated.
2024-02-18 11:39:00 +01:00
Jorg Adam Sowa
e7b1f2a95b
Change long2ip return type (#13395) 2024-02-16 17:11:18 +01:00
David CARLIER
eaaffae555
zend_call_stack sort of GH-13358 follow-up. (#13368)
for threaded context, it solely uses a new api only available on
illumos.
Here using a common older api to get the stack info for the current
thread.
while at it, completing stack_limit_010 test for these platforms.
2024-02-16 14:01:03 +00:00
Kévin Dunglas
f84d0468ed
add support for Zend Max Exeuction Timers on FreeBSD (#13393) 2024-02-16 12:45:15 +01:00
David CARLIER
aa1eaacc41
zend_ssa minor struct changes. (#13387)
_zend_ssa_pid::has_range_constraint being the only bool, the bitfield would not bring
any benefit.
2024-02-14 07:41:52 +00:00
Niels Dossche
5941cdaaad
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.
2024-02-13 21:43:03 +01:00
Michael Voříšek
87edeed3b9
Remove UNEXPECTED from typed prop checks
Closes GH-13143
2024-02-12 11:35:43 +01:00
Ayesh Karunaratne
f6f1f7c109
ext/standard: Minor improvements to phpinfo() output (#13371)
- Change `http://` links to `https://` for php.net and zend.com
 - Remove `<img border=0` attributes as they are no longer in the HTML standard
 - Replace `<font>` tags with `<span>` tags (used for highlight.* INI color value display previews)
2024-02-11 11:05:07 +01:00
Ilija Tovilo
59211a51b7
[skip ci] Move RFC1867 tests as requested by Jakub 2024-02-09 16:01:14 +01:00
Peter Kokot
968f048b4c
Fix undefined symbol pthread_attr_get_np on Solaris (#13358)
Solaris doesn't have pthread_attr_get_np().

Checked on Oracle Solaris 11.4.
2024-02-09 00:46:07 +01:00
Ilija Tovilo
cd66fcc68b
Add request_parse_body() function
RFC: https://wiki.php.net/rfc/rfc1867-non-post

This function allows populating the $_POST and $_FILES globals for non-post
requests. This avoids manual parsing of RFC1867 requests.

Fixes #55815
Closes GH-11472
2024-02-08 12:08:07 +01:00
Ilija Tovilo
2f894389b6
Revert "Use __attribute__((assume())) in ZEND_ASSUME when available"
This reverts commit bf4ec8bd9d.

Partial revert, keep the phpdbg changes.
2024-02-08 11:59:36 +01:00
Peter Kokot
e76f9e2b50
Remove DARWIN symbol (#13346)
When targeting Darwin systems (macOS, etc.), the compiler defines the
__APPLE__ symbol, which should be sufficient and a more established
detection method practice in these cases.
2024-02-07 21:07:48 +01:00
Derick Rethans
a4d64b2605
Removed ext/oci8 and ext/pdo_oci (#13327)
* Removed ext/oci8 and ext/pdo_oci

They now live in their own repositories:

https://github.com/php/pecl-database-oci8
https://github.com/php/pecl-database-pdo_oci

As per: https://wiki.php.net/rfc/unbundle_imap_pspell_oci8
2024-02-07 15:34:39 +00:00
Ilija Tovilo
c149b4f56f
Fix missing syntax error message in cli-server router script
Fixes GH-13113
Closes GH-13275
2024-02-07 16:13:08 +01:00
Ilija Tovilo
18cdfd3f51
Skip frameless functions with zend_execute_internal
zend_execute_internal is used to intercept function calls. We must use the
DO_FCALL opcode in this instance.
2024-02-07 16:05:15 +01:00
Ilija Tovilo
97e6c54336
Fix RC inference narrowing for ASSIGN_OBJ
Fixes oss-fuzz #66519
Closes GH-13345
2024-02-07 13:03:14 +01:00
Ilija Tovilo
0b1ab42ab8
Fix refactoring mistake
Odd, I rebuilt the project but somehow missed this.
2024-02-06 17:50:53 +01:00
Ilija Tovilo
631bc81607
Implement stackless internal function calls
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12461
2024-02-06 17:42:28 +01:00
David Carlier
b320aabc5e zend call stack fixing stack limit for macOs arm64.
8MB sounded a prudent size for older 10.9 macOs release, however
with newer mac with arm64, it triggers a stack overflow.

close GH-13319
2024-02-05 19:32:29 +00:00
Ilija Tovilo
f91833d297
Fix RC inference for DECLARE_LAMBDA_FUNCTION
It doesn't seem like the VM can return RCn. However, the JIT fails without it.
I'll need to look into this more closely.
2024-02-05 12:19:18 +01:00
Ilija Tovilo
79e8f20e56
Add type inference for various missing opcodes
Closes GH-13304
2024-02-05 11:48:48 +01:00
Niels Dossche
3b5986db69 Implement GH-12908: Show attribute name/class in ReflectionAttribute dump
This is consistent with how many other Reflection classes have a name
field, and it makes debugging easier.

Closes GH-12908.
Closes GH-12917.
2024-02-04 23:02:02 +01:00
David CARLIER
b8f10decb3
ZEND_ELEMENT_COUNT usage reduction. (#13324)
clang 18 is going to be released and in the meantime the counted_by
attribute usage had been constrained to true flexible arrays,
typical cases such as type name[1] ZEND_ELEMENT_COUNT(size) no longer
build.
2024-02-04 19:09:15 +00:00
David Carlier
f9a83a4bd4 fiber fix wrong asm directives on (default) solaris build mode.
Illumos/Solaris while being 64 bits produces by default 32 bits build.
In this case building the i386 assembly.

Close GH-13320
2024-02-04 17:39:24 +00:00