Commit graph

67 commits

Author SHA1 Message Date
Martin Schröder
a65989b127
Alternative Fiber Internals Refactoring (#7101) 2021-06-04 23:25:35 -05:00
Aaron Piotrowski
d2e5203865
Split fiber status and flags (#7094)
Co-Authored-By: twosee <twose@qq.com>
2021-06-03 15:34:48 -05:00
twosee
7e11b4d325
Improve memory allocation related code in zend_fibers (#7058)
- make_fcontext() never returns NULL.
- Show syscall error info in exception just like zend_alloc does (we also used php_win32_error_*() in Zend).
- MAP_ANON was marked as deprecated or compatibility macro on Linux, It would be better to use MAP_ANONYMOUS first.
- Makes the code consistent with the code of other modules in the kernel.
- adds some comments.
2021-05-28 12:04:44 +08:00
twosee
795efd7613
Add zend_getpagesize() and reuse it in accelerator and fiber (#7057) 2021-05-27 18:27:18 +08:00
Aaron Piotrowski
3939c9b07e
Add internal Fiber API (#7045)
This additional internal fiber API creates and manipulates a Fiber object, allowing any internal function to start, resume, or suspend a fiber. The existing zend_fiber_context API allows custom C-based fiber creation using the bundled switching context, but does not interact with the PHP VM. This API behaves the same as calling Fiber object methods from user code, switching EGs, and triggering the fiber switch observer. In general, the Fiber object methods call these new API methods.
2021-05-27 08:33:40 +02:00
twosee
0e2ac303af
Use ZEND_WIN32 instead of PHP_WIN32 (#7055) 2021-05-27 08:32:40 +02:00
Aaron Piotrowski
3c3ec441e4
Move fiber stack allocation within try
If VM stack allocation fails, the bailout will be caught within the fiber.
2021-05-08 23:30:48 -05:00
Aaron Piotrowski
5fb03758e5
Rename sanitizer members for clarity
These members hold the prior stack pointer and size, so bottom and capacity were poor name choices, prior_pointer and prior_size are more clear.
2021-05-08 13:12:06 -05:00
Aaron Piotrowski
af2905968c
Add sanitizer fiber switching support 2021-05-07 15:52:12 -05:00
Aaron Piotrowski
ccc069d0bb
Catch and repeat zend_bailout in fibers
This removes switching to main for fatal errors in fibers in favor of catching any zend_bailout in a fiber and calling zend_bailout again after switching to the previous fiber or {main}.
2021-05-07 15:52:11 -05:00
Aaron Piotrowski
779fe8e43a
Check current_execute_data instead of flags in fiber destructor
Checking EG(current_exectue_data) throws into the previous fiber instead of triggering a fatal error during shutdown. A fatal error is triggered only if the throwing destroyed fiber was resumed from {main}.
2021-05-05 10:48:30 -05:00
Nikita Popov
fb374f56a7 Rethrow exceptions in fiber destructor
We need to make sure that HANDLE_EXCEPTION is set when the fiber
throws during destruction.

Fixes oss-fuzz #33875.
2021-05-05 12:49:47 +02:00
Aaron Piotrowski
810fb59f66
Improve fiber backtraces
The start/resume/throw execute_data is now attached as the prev_execute_data to the bottom frame of the fiber stack when the fiber is running.
2021-04-30 12:17:50 -05:00
Aaron Piotrowski
f3465e6740
Minor fiber fixes
Assert error is fatal when calling zend_error_suspend_fiber.

Added missing static.

Removed .S extension from output of configure.
2021-04-30 10:08:01 -05:00
Aaron Piotrowski
4166653298
Fix exception thrown during fiber destruction
Previously an exception thrown during fiber destruction resulted in a fatal error, but that exception should be able to be caught (unless we’ve entered shutdown, then still use a fatal error so the error is not hidden).
2021-04-30 00:26:47 -05:00
Nikita Popov
e8e7c04a3a Use common struct to store error information
This is needed by both fibers and opcache (and GH-6903 also uses it),
so make it a common structure that can be used by any functionality
storing warnings/errors.
2021-04-29 11:50:54 +02:00
Aaron Piotrowski
c276c16b66
Implement Fibers
RFC: https://wiki.php.net/rfc/fibers

Closes GH-6875.
2021-04-26 11:07:06 -05:00