-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ext/pcre: Refactor preg_replace_callback(_array)()
to not pass a useless FCI
#17365
base: master
Are you sure you want to change the base?
Conversation
…able* This makes the assumption the zval is always an array explicit
We don't need the FCI anymore, and we always have the subject as a zend_string.
We don't need the FCI anymore
We don't need the FCI anymore Make the Hashtable param const Throw exception on non string entries
We don't need the FCI anymore Make the Hashtable params const Rename function to indicate it is a PHP pcre function
4d66c68
to
64f7aa1
Compare
64f7aa1
to
10435d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this PR is fine (and does more welcome cleanup than just the FCI stuff).
What I'm just not entirely convinced by is if in this particular case getting rid of FCI passing is a good idea. If we don't pass it, the engine makes an FCI itself and also needs to do a bit extra work when dealing with trampolines:
Lines 847 to 851 in 47f1cae
if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) { | |
func = (zend_function*) emalloc(sizeof(zend_function)); | |
memcpy(func, fcc->function_handler, sizeof(zend_function)); | |
zend_string_addref(func->op_array.function_name); | |
} |
But we already have an FCI anyway (that we don't store), so I'm not sure how much improvement this actually is.
pcre2_get_mark(match_data), flags); | ||
|
||
ZEND_ASSERT(eval_result); | ||
if (UNEXPECTED(eval_result == NULL)) { | ||
goto error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure this is right. This error path calls into pcre_handle_exec_error(count)
where count
represents an error code normally. However, in this call this is a real count and not an error code.
I was first thinking that you should probably set PCRE_G(error_code)
yourself. However, perhaps not even that is necessary because we're throwing a userland exception anyway (which is not a pcre error itself).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I wasn't exactly sure myself here.
Long term, I am trying to see if I can get rid of the |
And other drive-by refactorings.
This fixes an unclean shutdown with trampolines for
preg_replace_callback_array()
, I just don't know what causes it atm.