Validate task functions before execution#387
Open
realFlowControl wants to merge 10 commits into
Open
Conversation
realFlowControl
force-pushed
the
florian/phase-2-link-functions
branch
from
July 15, 2026 08:08
c388a1e to
7181cb3
Compare
This reverts commit c763ab3.
realFlowControl
force-pushed
the
florian/phase-2-link-functions
branch
from
July 15, 2026 08:22
e9640f9 to
a2d5e9d
Compare
realFlowControl
marked this pull request as ready for review
July 15, 2026 09:48
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.
What and why
Tasks run in an isolated runtime and do not inherit user-defined functions from the thread that submits them. Calling one of those functions without loading it in the destination runtime previously allowed the task to start before failing with a generic undefined-function error, so users could see partial task side effects without guidance about the actual dependency mistake. This change validates statically named function dependencies before executing the task and reports an actionable
parallel\Runtime\Error\IllegalInstructionthroughFuture::value()instead.The error identifies the missing function and explains the two supported ways to provide it: define it in the runtime bootstrap or pass a closure created with
Closure::fromCallable()as a task argument. Because validation happens before execution, no task statement runs when a static dependency is missing.Implementation
The scheduler performs the validation in the destination runtime immediately before
zend_execute_ex(), where the destination function table is available. It scansZEND_INIT_FCALL,ZEND_INIT_FCALL_BY_NAME, andZEND_INIT_NS_FCALL_BY_NAME, including namespace fallback, and recursively validates functions referenced byZEND_DECLARE_LAMBDA_FUNCTIONso nested closures have the same behavior.Each static call is resolved with
zend_fetch_function(). Direct calls also verify that the destination definition has a compatible call-frame size and seed the task's runtime-cache slot with that definition. A validation failure is converted into the existing future error path with the task source file and line, and the execution frame is cleaned up without running the task.Function names known only at runtime, such as
$function(), cannot be checked ahead of execution. Anincludeinside the task is too late to satisfy a static dependency because validation runs first. A same-name function already present in the destination runtime is accepted; definitions are not compared by source identity.The README now documents this task dependency boundary and the existing undefined-function regressions assert the new pre-execution diagnostic. A dedicated nested-closure regression ensures OPcache and JIT cannot optimize away the dependency being tested.
Testing