Skip to content

convert ZEND_INIT_FCALL to ZEND_INIT_FCALL_BY_NAME#356

Merged
realFlowControl merged 4 commits into
developfrom
florian/init-fcall-to-dynamic-call
Dec 17, 2025
Merged

convert ZEND_INIT_FCALL to ZEND_INIT_FCALL_BY_NAME#356
realFlowControl merged 4 commits into
developfrom
florian/init-fcall-to-dynamic-call

Conversation

@realFlowControl

@realFlowControl realFlowControl commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator

This PR migrates ZEND_INIT_FCALL opcodes to ZEND_INIT_FCALL_BY_NAME opcodes when copying the closure given to \parallel\run() or \parallel\Runtime::run() to the internal cache (in order to copy it to the thread it gets executed on). This is done because ZEND_INIT_FCALL is an optimised opcode for functions that are visible to the compiler at compile time and it does not do and runtime checks anymore and instead segfaults.

AFAIK this optimisation only triggers if the code looks something like this:

<?php
function foo() { return "OK"; }
$future = \parallel\run(function(){ 
    return foo(); 
});

This code is segfaulting (it won't if you \parallel\bootstrap("file_that_provides_foo_function.php");.
This PR make sure we do not segfault, but instead PHP raises a Fatal error: Call to undefined function foo() ... instead.

Fixes #317 for cases where OPcache is disabled

@realFlowControl realFlowControl changed the title convert ZEND_INIT_FCALL to ZEND_INIT_DYNAMIC_CALL convert ZEND_INIT_FCALL to ZEND_INIT_FCALL_BY_NAME Dec 16, 2025
@realFlowControl
realFlowControl force-pushed the florian/init-fcall-to-dynamic-call branch 2 times, most recently from 71b03e4 to 422955f Compare December 16, 2025 12:27
@realFlowControl
realFlowControl force-pushed the florian/init-fcall-to-dynamic-call branch from 422955f to 4049900 Compare December 16, 2025 12:32
@realFlowControl
realFlowControl marked this pull request as ready for review December 17, 2025 20:12
@realFlowControl
realFlowControl merged commit e90b328 into develop Dec 17, 2025
66 of 78 checks passed
@realFlowControl
realFlowControl deleted the florian/init-fcall-to-dynamic-call branch December 17, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

segfault when calling a function defined in global scope

1 participant