Handle calling functions from global scope#355
Merged
Conversation
realFlowControl
force-pushed
the
florian/handle-undefined-functions
branch
3 times, most recently
from
December 12, 2025 16:33
b90f408 to
fc53265
Compare
realFlowControl
force-pushed
the
florian/handle-undefined-functions
branch
from
December 12, 2025 16:40
fc53265 to
fad9905
Compare
realFlowControl
marked this pull request as ready for review
December 15, 2025 13:27
realFlowControl
force-pushed
the
florian/handle-undefined-functions
branch
from
December 17, 2025 20:07
cc03255 to
72e191d
Compare
realFlowControl
force-pushed
the
develop
branch
from
December 17, 2025 20:11
9376d37 to
14042a8
Compare
realFlowControl
added a commit
that referenced
this pull request
Jun 16, 2026
The Windows VEH is a process-wide first-chance handler and #355 used it as a catch-all for every access violation on a parallel worker. Narrowing it unmasked a latent shutdown access violation in functional/007 (bootstrap set inside a task) that crashes the process. That is a separate, Windows-only issue that needs a Windows repro to fix properly, so restore the VEH to its original catch-all behavior. The undefined-function narrowing (and the debugging benefit of not masking real crashes under sanitizers/gdb/core dumps) remains on the POSIX SIGSEGV handler, which is where it matters.
realFlowControl
added a commit
that referenced
this pull request
Jun 16, 2026
The SIGSEGV/VEH handler added in #355 caught *every* fault on a parallel worker thread and converted it into a catchable IllegalInstruction error via zend_bailout(). This masked genuine bugs (no backtrace, no core dump) and longjmp-ing out of a signal handler is not async-signal-safe. Restrict the conversion to the single case it was built for: a worker faulting on a ZEND_INIT_FCALL to a function that is not in the worker's function table (i.e. not provided via a bootstrap file). Any other fault now falls through to the previous handler so it crashes properly with a backtrace / core dump. Detection is factored into php_parallel_scheduler_recover_missing_function() shared by both the POSIX and Windows handlers.
realFlowControl
added a commit
that referenced
this pull request
Jun 16, 2026
The SIGSEGV/VEH handler added in #355 caught *every* fault on a parallel worker thread and converted it into a catchable IllegalInstruction error via zend_bailout(). This masked genuine bugs (no backtrace, no core dump) and longjmp-ing out of a signal handler is not async-signal-safe. Restrict the conversion to the single case it was built for: a worker faulting on a ZEND_INIT_FCALL to a function that is not in the worker's function table (i.e. not provided via a bootstrap file). Any other fault now falls through to the previous handler so it crashes properly with a backtrace / core dump.
This was referenced Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When calling a function from the global scope of the main thread in a task,
parallelcrashes depending on the PHP version and if you haveOPcacheenabled or not (see #317).Copying the
function_tablefrom the parent thread seems possible, but it is complex, error-prone, and, due to the highly dynamic nature of PHP, nearly impossible to perform with 100% accuracy.How does the crashing code look:
paralleldoes not copy functions from the main threadsfunction_tableto the task's thread. You need to make those functions available using a bootstrap file:This PR adds a
SIGSEGVhandler that catches this crash (and other segmentation faults) and raises an exception that get's thrown when the$future->value()function is called. Additionally this runtime get's shutdown, so for parallel managed runtimes through\parallel\run()you will not notice any difference (just in CPU cycles, asparallelhas to create a new runtime if you schedule a new task), for runtimes created usingnew \parallel\Runtime()you will notice that after a crash you can't schedule a new task on that runtime anymore. When calling$runtime->run()it'll throw a\parallel\Runtime\Error\Closed()exception instead of scheduling the task to be run.Fixes #317