Skip to content

Instantly share code, notes, and snippets.

View dstogov's full-sized avatar

Dmitry Stogov dstogov

  • Zend by Perforce
  • Russia
View GitHub Profile
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 491d68714b3..20c830db03f 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -1081,13 +1081,13 @@ static void perform_delayable_implementation_check(
/**
* @param check_only Set to false to throw compile errors on incompatible methods, or true to return INHERITANCE_ERROR.
* @param checked Whether the compatibility check has already succeeded in zend_can_early_bind().
- * @param force_mutable Whether we know that child may be modified, i.e. doesn't live in shm.
+ * @param child_zv the zval where the "child" may be cloned. It's NULL if we don't need cloning.
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 491d68714b3..155156478bf 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -1139,6 +1139,13 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
}
if (!check_only && (parent_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_CHANGED))) {
+ if (child_scope != ce && child->type == ZEND_USER_FUNCTION && child_zv) {
+ /* op_array wasn't duplicated yet */
@dstogov
dstogov / gist:3581cd91d42b6fce97a3c1e2870937c2
Created March 20, 2024 14:22
observer_validate_opline-01.diff
diff --git a/ext/zend_test/observer.c b/ext/zend_test/observer.c
index 3e870de450a..00e6aec877b 100644
--- a/ext/zend_test/observer.c
+++ b/ext/zend_test/observer.c
@@ -347,6 +347,25 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("zend_test.observer.execute_internal", "0", PHP_INI_SYSTEM, OnUpdateBool, observer_execute_internal, zend_zend_test_globals, zend_test_globals)
PHP_INI_END()
+static void validate_opline_observer_begin(zend_execute_data *ex)
+{
diff --git a/Zend/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c
index 463bbbfa84b..523c829fdab 100644
--- a/Zend/Optimizer/zend_optimizer.c
+++ b/Zend/Optimizer/zend_optimizer.c
@@ -1330,6 +1330,44 @@ static void zend_redo_pass_two_ex(zend_op_array *op_array, zend_ssa *ssa)
}
break;
}
+#ifdef ZEND_VERIFY_TYPE_INFERENCE
+ if (ssa_op->op1_use >= 0) {
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index fd1705149b..d1fe6f12b4 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2175,6 +2175,13 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
}
while (ptr->fname) {
+ if (ptr->flags == ZEND_LIGHT_FUNC) {
+ internal_function->light_handler = (zif_light_handler)ptr->handler;
diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c
index b1fbc7b651..e2a7e599d7 100644
--- a/ext/opcache/jit/zend_jit_trace.c
+++ b/ext/opcache/jit/zend_jit_trace.c
@@ -6823,7 +6823,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
if (!(t->flags & ZEND_JIT_TRACE_USES_INITIAL_IP)
|| (ra
&& zend_jit_trace_stack_needs_deoptimization(stack, op_array->last_var + op_array->T))) {
- uint32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM);
+ /* Deoptimize to the first instruction of the loop */
diff --git a/CODEOWNERS b/CODEOWNERS
index 87f1e79d22..c052ac48be 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -9,6 +9,25 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
/.github @iluuu1994
-/ext/opcache @iluuu1994
+/ext/ffi @dstogov
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index 6f7fef32a0..151afadec2 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -726,10 +726,25 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
/* Fast class cache */
#define ZSTR_HAS_CE_CACHE(s) (GC_FLAGS(s) & IS_STR_CLASS_NAME_MAP_PTR)
-#define ZSTR_GET_CE_CACHE(s) \
- (*(zend_class_entry **)ZEND_MAP_PTR_OFFSET2PTR(GC_REFCOUNT(s)))
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 9979a9b2fb..a98a3480d3 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -9857,6 +9857,20 @@ ZEND_VM_HELPER(zend_interrupt_helper, ANY, ANY)
zend_timeout();
} else if (zend_interrupt_function) {
zend_interrupt_function(execute_data);
+ if (EG(exception)) {
+ /* We have to UNDEF result, because ZEND_HANDLE_EXCEPTION is going to free it */
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index a2cc930b2f..bbab942b96 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -4578,7 +4578,9 @@ finish:
static size_t preload_ub_write(const char *str, size_t str_length)
{
- return fwrite(str, 1, str_length, stdout);
+ size_t ret = fwrite(str, 1, str_length, stdout);