php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_execute_API.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 2.00 of the Zend license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.zend.com/license/2_00.txt. |
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@php.net> |
16 | Zeev Suraski <zeev@php.net> |
17 | Dmitry Stogov <dmitry@php.net> |
18 +----------------------------------------------------------------------+
19*/
20
21#include <stdio.h>
22#include <signal.h>
23
24#include "zend.h"
25#include "zend_compile.h"
26#include "zend_execute.h"
27#include "zend_API.h"
28#include "zend_stack.h"
29#include "zend_constants.h"
30#include "zend_extensions.h"
31#include "zend_exceptions.h"
32#include "zend_closures.h"
33#include "zend_generators.h"
34#include "zend_vm.h"
35#include "zend_float.h"
36#include "zend_fibers.h"
37#include "zend_weakrefs.h"
38#include "zend_inheritance.h"
39#include "zend_observer.h"
40#include "zend_call_stack.h"
42#ifdef HAVE_SYS_TIME_H
43#include <sys/time.h>
44#endif
45#ifdef HAVE_UNISTD_H
46#include <unistd.h>
47#endif
48#ifdef ZEND_MAX_EXECUTION_TIMERS
49#include <sys/syscall.h>
50#endif
51
55
56/* true globals */
59
60#ifdef ZEND_WIN32
61ZEND_TLS HANDLE tq_timer = NULL;
62#endif
63
64#if 0&&ZEND_DEBUG
65static void (*original_sigsegv_handler)(int);
66static void zend_handle_sigsegv(void) /* {{{ */
67{
68 fflush(stdout);
69 fflush(stderr);
70 if (original_sigsegv_handler == zend_handle_sigsegv) {
71 signal(SIGSEGV, original_sigsegv_handler);
72 } else {
73 signal(SIGSEGV, SIG_DFL);
74 }
75 {
76
77 fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
78 active_opline->opcode,
79 active_opline-EG(active_op_array)->opcodes,
83/* See http://support.microsoft.com/kb/190351 */
84#ifdef ZEND_WIN32
85 fflush(stderr);
86#endif
87 }
88 if (original_sigsegv_handler!=zend_handle_sigsegv) {
89 original_sigsegv_handler(dummy);
90 }
91}
92/* }}} */
93#endif
94
95static void zend_extension_activator(zend_extension *extension) /* {{{ */
96{
97 if (extension->activate) {
98 extension->activate();
99 }
100}
101/* }}} */
102
103static void zend_extension_deactivator(zend_extension *extension) /* {{{ */
104{
105 if (extension->deactivate) {
106 extension->deactivate();
107 }
108}
109/* }}} */
110
111static int clean_non_persistent_constant_full(zval *zv) /* {{{ */
112{
115}
116/* }}} */
117
118static int clean_non_persistent_function_full(zval *zv) /* {{{ */
119{
122}
123/* }}} */
124
125static int clean_non_persistent_class_full(zval *zv) /* {{{ */
126{
129}
130/* }}} */
131
132void init_executor(void) /* {{{ */
133{
135
136 ZVAL_NULL(&EG(uninitialized_zval));
137 ZVAL_ERROR(&EG(error_zval));
138/* destroys stack frame, therefore makes core dumps worthless */
139#if 0&&ZEND_DEBUG
140 original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);
141#endif
142
143 EG(symtable_cache_ptr) = EG(symtable_cache);
144 EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE;
145 EG(no_extensions) = 0;
146
147 EG(function_table) = CG(function_table);
148 EG(class_table) = CG(class_table);
149
150 EG(in_autoload) = NULL;
151 EG(error_handling) = EH_NORMAL;
153
155
156 zend_hash_init(&EG(symbol_table), 64, NULL, ZVAL_PTR_DTOR, 0);
157
158 zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator);
159
160 zend_hash_init(&EG(included_files), 8, NULL, NULL, 0);
161
162 EG(ticks_count) = 0;
163
164 ZVAL_UNDEF(&EG(user_error_handler));
165 ZVAL_UNDEF(&EG(user_exception_handler));
166
167 EG(current_execute_data) = NULL;
168
169 zend_stack_init(&EG(user_error_handlers_error_reporting), sizeof(int));
170 zend_stack_init(&EG(user_error_handlers), sizeof(zval));
171 zend_stack_init(&EG(user_exception_handlers), sizeof(zval));
172
173 zend_objects_store_init(&EG(objects_store), 1024);
174 zend_lazy_objects_init(&EG(lazy_objects_store));
175
176 EG(full_tables_cleanup) = 0;
177 ZEND_ATOMIC_BOOL_INIT(&EG(vm_interrupt), false);
178 ZEND_ATOMIC_BOOL_INIT(&EG(timed_out), false);
179
180 EG(exception) = NULL;
181 EG(prev_exception) = NULL;
182
183 EG(fake_scope) = NULL;
184 EG(trampoline).common.function_name = NULL;
185
186 EG(ht_iterators_count) = sizeof(EG(ht_iterators_slots)) / sizeof(HashTableIterator);
187 EG(ht_iterators_used) = 0;
188 EG(ht_iterators) = EG(ht_iterators_slots);
189 memset(EG(ht_iterators), 0, sizeof(EG(ht_iterators_slots)));
190
191 EG(persistent_constants_count) = EG(zend_constants)->nNumUsed;
192 EG(persistent_functions_count) = EG(function_table)->nNumUsed;
193 EG(persistent_classes_count) = EG(class_table)->nNumUsed;
194
195 EG(get_gc_buffer).start = EG(get_gc_buffer).end = EG(get_gc_buffer).cur = NULL;
196
197 EG(record_errors) = false;
198 EG(num_errors) = 0;
199 EG(errors) = NULL;
200
201 EG(filename_override) = NULL;
202 EG(lineno_override) = -1;
203
207
208 EG(active) = 1;
209}
210/* }}} */
211
212static int zval_call_destructor(zval *zv) /* {{{ */
213{
214 if (Z_TYPE_P(zv) == IS_INDIRECT) {
215 zv = Z_INDIRECT_P(zv);
216 }
217 if (Z_TYPE_P(zv) == IS_OBJECT && Z_REFCOUNT_P(zv) == 1) {
219 } else {
221 }
222}
223/* }}} */
224
225static void zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */
226{
227 if (Z_TYPE_P(zv) == IS_INDIRECT) {
228 zv = Z_INDIRECT_P(zv);
229 }
230 i_zval_ptr_dtor(zv);
231}
232/* }}} */
233
234static ZEND_COLD void zend_throw_or_error(int fetch_type, zend_class_entry *exception_ce, const char *format, ...) /* {{{ */
235{
236 va_list va;
237 char *message = NULL;
238
239 va_start(va, format);
240 zend_vspprintf(&message, 0, format, va);
241
242 if (fetch_type & ZEND_FETCH_CLASS_EXCEPTION) {
243 zend_throw_error(exception_ce, "%s", message);
244 } else {
245 zend_error_noreturn(E_ERROR, "%s", message);
246 }
247
248 efree(message);
249 va_end(va);
250}
251/* }}} */
252
253void shutdown_destructors(void) /* {{{ */
254{
255 if (CG(unclean_shutdown)) {
256 EG(symbol_table).pDestructor = zend_unclean_zval_ptr_dtor;
257 }
258 zend_try {
259 uint32_t symbols;
260 do {
261 symbols = zend_hash_num_elements(&EG(symbol_table));
262 zend_hash_reverse_apply(&EG(symbol_table), (apply_func_t) zval_call_destructor);
263 } while (symbols != zend_hash_num_elements(&EG(symbol_table)));
265 } zend_catch {
266 /* if we couldn't destruct cleanly, mark all objects as destructed anyway */
267 zend_objects_store_mark_destructed(&EG(objects_store));
268 } zend_end_try();
269}
270/* }}} */
271
272/* Free values held by the executor. */
274{
276 zval *zv;
277
279 zend_try {
280 zend_close_rsrc_list(&EG(regular_list));
281 } zend_end_try();
282
283 /* No PHP callback functions should be called after this point. */
284 EG(active) = 0;
285
286 if (!fast_shutdown) {
288
289 /* Constants may contain objects, destroy them before the object store. */
290 if (EG(full_tables_cleanup)) {
291 zend_hash_reverse_apply(EG(zend_constants), clean_non_persistent_constant_full);
292 } else {
295 if (_idx == EG(persistent_constants_count)) {
296 break;
297 }
298 zval_ptr_dtor_nogc(&c->value);
299 if (c->name) {
301 }
302 efree(c);
305 }
306
307 /* Release static properties and static variables prior to the final GC run,
308 * as they may hold GC roots. */
309 ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(function_table), zv) {
310 zend_op_array *op_array = Z_PTR_P(zv);
311 if (op_array->type == ZEND_INTERNAL_FUNCTION) {
312 break;
313 }
314 if (ZEND_MAP_PTR(op_array->static_variables_ptr)) {
315 HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
316 if (ht) {
318 ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL);
319 }
320 }
324
327 }
328
329 if (ZEND_MAP_PTR(ce->mutable_data)) {
330 if (ZEND_MAP_PTR_GET_IMM(ce->mutable_data)) {
332 }
333 } else if (ce->type == ZEND_USER_CLASS && !(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
334 /* Constants may contain objects, destroy the values before the object store. */
337 if (c->ce == ce) {
338 zval_ptr_dtor_nogc(&c->value);
339 ZVAL_UNDEF(&c->value);
340 }
342
343 /* properties may contain objects as well */
344 if (ce->default_properties_table) {
347
348 while (p != end) {
349 i_zval_ptr_dtor(p);
350 ZVAL_UNDEF(p);
351 p++;
352 }
353 }
354 }
355
356 if (ce->type == ZEND_USER_CLASS && ce->backed_enum_table) {
358 zend_hash_release(ce->backed_enum_table);
360 }
361
363 zend_op_array *op_array;
365 if (op_array->type == ZEND_USER_FUNCTION) {
366 if (ZEND_MAP_PTR(op_array->static_variables_ptr)) {
367 HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
368 if (ht) {
370 ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL);
371 }
372 }
373 }
375
376 if (ce->num_hooked_props) {
379 if (prop_info->ce == ce) {
380 if (prop_info->hooks) {
381 for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
382 if (prop_info->hooks[i]) {
383 ZEND_ASSERT(ZEND_USER_CODE(prop_info->hooks[i]->type));
384 op_array = &prop_info->hooks[i]->op_array;
385 if (ZEND_MAP_PTR(op_array->static_variables_ptr)) {
386 HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
387 if (ht) {
389 ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL);
390 }
391 }
392 }
393 }
394 }
395 }
397 }
398 }
400
401 /* Also release error and exception handlers, which may hold objects. */
402 if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
403 zval_ptr_dtor(&EG(user_error_handler));
404 ZVAL_UNDEF(&EG(user_error_handler));
405 }
406
407 if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
408 zval_ptr_dtor(&EG(user_exception_handler));
409 ZVAL_UNDEF(&EG(user_exception_handler));
410 }
411
412 zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);
413 zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
414 zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
415
416#if ZEND_DEBUG
417 if (!CG(unclean_shutdown)) {
419 }
420#endif
421 } else {
422 zend_hash_discard(EG(zend_constants), EG(persistent_constants_count));
423 }
424
425 zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown);
426}
427
428void shutdown_executor(void) /* {{{ */
429{
431 zval *zv;
432#if ZEND_DEBUG
433 bool fast_shutdown = 0;
434#else
435 bool fast_shutdown = is_zend_mm() && !EG(full_tables_cleanup);
436#endif
437
438 zend_try {
440 } zend_end_try();
441
442 zend_shutdown_executor_values(fast_shutdown);
443
447
448 zend_try {
449 zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator);
450 } zend_end_try();
451
452 if (fast_shutdown) {
453 /* Fast Request Shutdown
454 * =====================
455 * Zend Memory Manager frees memory by its own. We don't have to free
456 * each allocated block separately.
457 */
458 zend_hash_discard(EG(function_table), EG(persistent_functions_count));
459 zend_hash_discard(EG(class_table), EG(persistent_classes_count));
460 } else {
462
463 if (EG(full_tables_cleanup)) {
464 zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full);
465 zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class_full);
466 } else {
469 if (_idx == EG(persistent_functions_count)) {
470 break;
471 }
472 destroy_op_array(&func->op_array);
475
477 if (_idx == EG(persistent_classes_count)) {
478 break;
479 }
483 }
484
485 while (EG(symtable_cache_ptr) > EG(symtable_cache)) {
486 EG(symtable_cache_ptr)--;
487 zend_hash_destroy(*EG(symtable_cache_ptr));
488 FREE_HASHTABLE(*EG(symtable_cache_ptr));
489 }
490
491 zend_hash_destroy(&EG(included_files));
492
493 zend_stack_destroy(&EG(user_error_handlers_error_reporting));
494 zend_stack_destroy(&EG(user_error_handlers));
495 zend_stack_destroy(&EG(user_exception_handlers));
496 zend_lazy_objects_destroy(&EG(lazy_objects_store));
497 zend_objects_store_destroy(&EG(objects_store));
498 if (EG(in_autoload)) {
499 zend_hash_destroy(EG(in_autoload));
500 FREE_HASHTABLE(EG(in_autoload));
501 }
502
503 if (EG(ht_iterators) != EG(ht_iterators_slots)) {
504 efree(EG(ht_iterators));
505 }
506 }
507
508#if ZEND_DEBUG
509 if (EG(ht_iterators_used) && !CG(unclean_shutdown)) {
510 zend_error(E_WARNING, "Leaked %" PRIu32 " hashtable iterators", EG(ht_iterators_used));
511 }
512#endif
513
514 /* Check whether anyone is hogging the trampoline. */
515 ZEND_ASSERT(EG(trampoline).common.function_name == NULL || CG(unclean_shutdown));
516
517 EG(ht_iterators_used) = 0;
518
520}
521/* }}} */
522
523/* return class name and "::" or "". */
524ZEND_API const char *get_active_class_name(const char **space) /* {{{ */
525{
527
528 if (!zend_is_executing()) {
529 if (space) {
530 *space = "";
531 }
532 return "";
533 }
534
535 func = zend_active_function();
536
537 switch (func->type) {
540 {
541 zend_class_entry *ce = func->common.scope;
542
543 if (space) {
544 *space = ce ? "::" : "";
545 }
546 return ce ? ZSTR_VAL(ce->name) : "";
547 }
548 default:
549 if (space) {
550 *space = "";
551 }
552 return "";
553 }
554}
555/* }}} */
556
557ZEND_API const char *get_active_function_name(void) /* {{{ */
558{
560
561 if (!zend_is_executing()) {
562 return NULL;
563 }
564
565 func = zend_active_function();
566
567 switch (func->type) {
568 case ZEND_USER_FUNCTION: {
569 zend_string *function_name = func->common.function_name;
570
571 if (function_name) {
572 return ZSTR_VAL(function_name);
573 } else {
574 return "main";
575 }
576 }
577 break;
579 return ZSTR_VAL(func->common.function_name);
580 break;
581 default:
582 return NULL;
583 }
584}
585/* }}} */
586
588{
590
591 /* Resolve function if op is a frameless call. */
592 if (ZEND_USER_CODE(func->type)) {
593 const zend_op *op = EX(opline);
595 func = ZEND_FLF_FUNC(op);
596 }
597 }
598
599 return func;
600}
601
603{
605
606 return get_function_or_method_name(zend_active_function());
607}
608/* }}} */
609
611{
612 if (func->common.scope && func->common.function_name) {
613 return zend_create_member_string(func->common.scope->name, func->common.function_name);
614 }
615
616 return func->common.function_name ? zend_string_copy(func->common.function_name) : ZSTR_INIT_LITERAL("main", 0);
617}
618/* }}} */
619
620ZEND_API const char *get_active_function_arg_name(uint32_t arg_num) /* {{{ */
621{
622 if (!zend_is_executing()) {
623 return NULL;
624 }
625
626 zend_function *func = zend_active_function();
627
629}
630/* }}} */
631
632ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t arg_num) /* {{{ */
633{
634 if (!func || arg_num == 0 || func->common.num_args < arg_num) {
635 return NULL;
636 }
637
638 if (func->type == ZEND_USER_FUNCTION || (func->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
639 return ZSTR_VAL(func->common.arg_info[arg_num - 1].name);
640 } else {
641 return ((zend_internal_arg_info*) func->common.arg_info)[arg_num - 1].name;
642 }
643}
644/* }}} */
645
646ZEND_API const char *zend_get_executed_filename(void) /* {{{ */
647{
649 return filename != NULL ? ZSTR_VAL(filename) : "[no active file]";
650}
651/* }}} */
652
654{
655 zend_string *filename_override = EG(filename_override);
656 if (filename_override != NULL) {
657 return filename_override;
658 }
659
660 zend_execute_data *ex = EG(current_execute_data);
661
662 while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
663 ex = ex->prev_execute_data;
664 }
665 if (ex) {
666 return ex->func->op_array.filename;
667 } else {
668 return NULL;
669 }
670}
671/* }}} */
672
673ZEND_API uint32_t zend_get_executed_lineno(void) /* {{{ */
674{
675 zend_long lineno_override = EG(lineno_override);
676 if (lineno_override != -1) {
677 return lineno_override;
678 }
679
680 zend_execute_data *ex = EG(current_execute_data);
681
682 while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
683 ex = ex->prev_execute_data;
684 }
685 if (ex) {
686 if (!ex->opline) {
687 /* Missing SAVE_OPLINE()? Falling back to first line of function */
688 return ex->func->op_array.opcodes[0].lineno;
689 }
690 if (EG(exception) && ex->opline->opcode == ZEND_HANDLE_EXCEPTION &&
691 ex->opline->lineno == 0 && EG(opline_before_exception)) {
692 return EG(opline_before_exception)->lineno;
693 }
694 return ex->opline->lineno;
695 } else {
696 return 0;
697 }
698}
699/* }}} */
700
702{
703 zend_execute_data *ex = EG(current_execute_data);
704
705 while (1) {
706 if (!ex) {
707 return NULL;
708 } else if (ex->func && (ZEND_USER_CODE(ex->func->type) || ex->func->common.scope)) {
709 return ex->func->common.scope;
710 }
711 ex = ex->prev_execute_data;
712 }
713}
714/* }}} */
715
716ZEND_API bool zend_is_executing(void) /* {{{ */
717{
718 return EG(current_execute_data) != 0;
719}
720/* }}} */
721
723{
724 if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
725 zend_ast *ast = Z_ASTVAL_P(p);
726
727 if (ast->kind == ZEND_AST_CONSTANT) {
728 zend_string *name = zend_ast_get_constant_name(ast);
730 if (UNEXPECTED(zv == NULL)) {
731 return FAILURE;
732 }
733
734 zval_ptr_dtor_nogc(p);
736 } else {
737 zval tmp;
738 bool short_circuited;
739
740 // Increase the refcount during zend_ast_evaluate to avoid releasing the ast too early
741 // on nested calls to zval_update_constant_ex which can happen when retriggering ast
742 // evaluation during autoloading.
743 zend_ast_ref *ast_ref = Z_AST_P(p);
744 bool ast_is_refcounted = !(GC_FLAGS(ast_ref) & GC_IMMUTABLE);
745 if (ast_is_refcounted) {
746 GC_ADDREF(ast_ref);
747 }
748 zend_result result = zend_ast_evaluate_ex(&tmp, ast, scope, &short_circuited, ctx) != SUCCESS;
749 if (ast_is_refcounted && !GC_DELREF(ast_ref)) {
750 rc_dtor_func((zend_refcounted *)ast_ref);
751 }
752 if (UNEXPECTED(result != SUCCESS)) {
753 return FAILURE;
754 }
755 zval_ptr_dtor_nogc(p);
756 ZVAL_COPY_VALUE(p, &tmp);
757 }
758 }
759 return SUCCESS;
760}
761/* }}} */
762
768
770{
771 return zval_update_constant_ex(pp, EG(current_execute_data) ? zend_get_executed_scope() : CG(active_class_entry));
772}
773/* }}} */
774
775zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */
776{
777 zend_fcall_info fci;
778
779 fci.size = sizeof(fci);
780 if (object) {
781 ZEND_ASSERT(Z_TYPE_P(object) == IS_OBJECT);
782 fci.object = Z_OBJ_P(object);
783 } else {
784 fci.object = NULL;
785 }
786 ZVAL_COPY_VALUE(&fci.function_name, function_name);
787 fci.retval = retval_ptr;
788 fci.param_count = param_count;
789 fci.params = params;
790 fci.named_params = named_params;
791
792 return zend_call_function(&fci, NULL);
793}
794/* }}} */
795
797{
798 uint32_t i;
800 zend_fcall_info_cache fci_cache_local;
802 uint32_t call_info;
803 void *object_or_called_scope;
804 zend_class_entry *orig_fake_scope;
805
806 ZVAL_UNDEF(fci->retval);
807
808 if (!EG(active)) {
809 return FAILURE; /* executor is already inactive */
810 }
811
812 if (EG(exception)) {
813 if (fci_cache) {
815 }
816 return SUCCESS; /* we would result in an unstable executor otherwise */
817 }
818
819 ZEND_ASSERT(fci->size == sizeof(zend_fcall_info));
820
821 if (!fci_cache || !fci_cache->function_handler) {
822 char *error = NULL;
823
824 if (!fci_cache) {
825 fci_cache = &fci_cache_local;
826 }
827
828 if (!zend_is_callable_ex(&fci->function_name, fci->object, 0, NULL, fci_cache, &error)) {
829 ZEND_ASSERT(error && "Should have error if not callable");
830 zend_string *callable_name
832 zend_throw_error(NULL, "Invalid callback %s, %s", ZSTR_VAL(callable_name), error);
833 efree(error);
834 zend_string_release_ex(callable_name, 0);
835 return SUCCESS;
836 }
837
839 }
840
841 func = fci_cache->function_handler;
842 if ((func->common.fn_flags & ZEND_ACC_STATIC) || !fci_cache->object) {
843 object_or_called_scope = fci_cache->called_scope;
845 } else {
846 object_or_called_scope = fci_cache->object;
848 }
849
850 call = zend_vm_stack_push_call_frame(call_info,
851 func, fci->param_count, object_or_called_scope);
852
853 if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_DEPRECATED)) {
855
856 if (UNEXPECTED(EG(exception))) {
857 zend_vm_stack_free_call_frame(call);
858 return SUCCESS;
859 }
860 }
861
862 for (i=0; i<fci->param_count; i++) {
863 zval *param = ZEND_CALL_ARG(call, i+1);
864 zval *arg = &fci->params[i];
865 bool must_wrap = 0;
866 if (UNEXPECTED(Z_ISUNDEF_P(arg))) {
867 /* Allow forwarding undef slots. This is only used by Closure::__invoke(). */
868 ZVAL_UNDEF(param);
870 continue;
871 }
872
873 if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) {
874 if (UNEXPECTED(!Z_ISREF_P(arg))) {
875 if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) {
876 /* By-value send is not allowed -- emit a warning,
877 * and perform the call with the value wrapped in a reference. */
879 must_wrap = 1;
880 if (UNEXPECTED(EG(exception))) {
882cleanup_args:
883 zend_vm_stack_free_args(call);
885 zend_free_extra_named_params(call->extra_named_params);
886 }
887 zend_vm_stack_free_call_frame(call);
889 return SUCCESS;
890 }
891 }
892 }
893 } else {
894 if (Z_ISREF_P(arg) &&
895 !(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
896 /* don't separate references for __call */
897 arg = Z_REFVAL_P(arg);
898 }
899 }
900
901 if (EXPECTED(!must_wrap)) {
902 ZVAL_COPY(param, arg);
903 } else {
905 ZVAL_NEW_REF(param, arg);
906 }
907 }
908
909 if (fci->named_params) {
911 zval *arg;
912 uint32_t arg_num = ZEND_CALL_NUM_ARGS(call) + 1;
913 bool have_named_params = 0;
915 bool must_wrap = 0;
916 zval *target;
917 if (name) {
918 void *cache_slot[2] = {NULL, NULL};
919 have_named_params = 1;
920 target = zend_handle_named_arg(&call, name, &arg_num, cache_slot);
921 if (!target) {
922 goto cleanup_args;
923 }
924 } else {
925 if (have_named_params) {
927 "Cannot use positional argument after named argument");
928 goto cleanup_args;
929 }
930
931 zend_vm_stack_extend_call_frame(&call, arg_num - 1, 1);
932 target = ZEND_CALL_ARG(call, arg_num);
933 }
934
936 if (UNEXPECTED(!Z_ISREF_P(arg))) {
938 /* By-value send is not allowed -- emit a warning,
939 * and perform the call with the value wrapped in a reference. */
941 must_wrap = 1;
942 if (UNEXPECTED(EG(exception))) {
943 goto cleanup_args;
944 }
945 }
946 }
947 } else {
948 if (Z_ISREF_P(arg) &&
949 !(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
950 /* don't separate references for __call */
951 arg = Z_REFVAL_P(arg);
952 }
953 }
954
955 if (EXPECTED(!must_wrap)) {
956 ZVAL_COPY(target, arg);
957 } else {
959 ZVAL_NEW_REF(target, arg);
960 }
961 if (!name) {
963 arg_num++;
964 }
966 }
967
969 /* zend_handle_undef_args assumes prev_execute_data is initialized. */
970 call->prev_execute_data = NULL;
972 zend_vm_stack_free_args(call);
973 zend_vm_stack_free_call_frame(call);
974 return SUCCESS;
975 }
976 }
977
978 if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) {
979 uint32_t call_info;
980
983 if (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) {
985 }
987 }
988
989 if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
990 fci_cache->function_handler = NULL;
991 }
992
993 orig_fake_scope = EG(fake_scope);
994 EG(fake_scope) = NULL;
995 if (func->type == ZEND_USER_FUNCTION) {
996 uint32_t orig_jit_trace_num = EG(jit_trace_num);
997
998 zend_init_func_execute_data(call, &func->op_array, fci->retval);
1001 EG(jit_trace_num) = orig_jit_trace_num;
1002 } else {
1004 ZVAL_NULL(fci->retval);
1005 call->prev_execute_data = EG(current_execute_data);
1006 EG(current_execute_data) = call;
1007#if ZEND_DEBUG
1008 bool should_throw = zend_internal_call_should_throw(func, call);
1009#endif
1012 /* saves one function call if zend_execute_internal is not used */
1013 func->internal_function.handler(call, fci->retval);
1014 } else {
1016 }
1017
1018#if ZEND_DEBUG
1019 if (!EG(exception) && call->func) {
1020 if (should_throw) {
1021 zend_internal_call_arginfo_violation(call->func);
1022 }
1023 ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
1024 zend_verify_internal_return_type(call->func, fci->retval));
1025 ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
1026 ? Z_ISREF_P(fci->retval) : !Z_ISREF_P(fci->retval));
1027 }
1028#endif
1030 EG(current_execute_data) = call->prev_execute_data;
1031 zend_vm_stack_free_args(call);
1033 zend_array_release(call->extra_named_params);
1034 }
1035
1036 if (EG(exception)) {
1037 zval_ptr_dtor(fci->retval);
1038 ZVAL_UNDEF(fci->retval);
1039 }
1040
1041 /* This flag is regularly checked while running user functions, but not internal
1042 * So see whether interrupt flag was set while the function was running... */
1043 if (zend_atomic_bool_exchange_ex(&EG(vm_interrupt), false)) {
1044 if (zend_atomic_bool_load_ex(&EG(timed_out))) {
1045 zend_timeout();
1046 } else if (zend_interrupt_function) {
1047 zend_interrupt_function(EG(current_execute_data));
1048 }
1049 }
1050
1052 OBJ_RELEASE(Z_OBJ(call->This));
1053 }
1054 }
1055 EG(fake_scope) = orig_fake_scope;
1056
1057 zend_vm_stack_free_call_frame(call);
1058
1059 if (UNEXPECTED(EG(exception))) {
1060 if (UNEXPECTED(!EG(current_execute_data))) {
1062 } else if (EG(current_execute_data)->func &&
1063 ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) {
1064 zend_rethrow_exception(EG(current_execute_data));
1065 }
1066 }
1067
1068 return SUCCESS;
1069}
1070/* }}} */
1071
1073 zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr,
1074 uint32_t param_count, zval *params, HashTable *named_params)
1075{
1076 zval retval;
1077 zend_fcall_info fci;
1079
1080 ZEND_ASSERT(fn && "zend_function must be passed!");
1081
1082 fci.size = sizeof(fci);
1083 fci.object = object;
1085 fci.param_count = param_count;
1086 fci.params = params;
1087 fci.named_params = named_params;
1088 ZVAL_UNDEF(&fci.function_name); /* Unused */
1089
1090 fcic.function_handler = fn;
1091 fcic.object = object;
1092 fcic.called_scope = called_scope;
1093
1094 zend_result result = zend_call_function(&fci, &fcic);
1095 if (UNEXPECTED(result == FAILURE)) {
1096 if (!EG(exception)) {
1097 zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s",
1098 fn->common.scope ? ZSTR_VAL(fn->common.scope->name) : "",
1099 fn->common.scope ? "::" : "", ZSTR_VAL(fn->common.function_name));
1100 }
1101 }
1102
1103 if (!retval_ptr) {
1105 }
1106}
1107
1109 zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2)
1110{
1111 zval params[2];
1112 ZVAL_COPY_VALUE(&params[0], param1);
1113 ZVAL_COPY_VALUE(&params[1], param2);
1114 zend_call_known_instance_method(fn, object, retval_ptr, 2, params);
1115}
1116
1118 zend_object *object, zend_string *method_name, zval *retval,
1119 uint32_t param_count, zval *params)
1120{
1121 zend_fcall_info fci;
1122 fci.size = sizeof(zend_fcall_info);
1123 fci.object = object;
1124 ZVAL_STR(&fci.function_name, method_name);
1125 fci.retval = retval;
1126 fci.param_count = param_count;
1127 fci.params = params;
1128 fci.named_params = NULL;
1129
1133 return FAILURE;
1134 }
1135
1136 return zend_call_function(&fci, &fcc);
1137}
1138
1139/* 0-9 a-z A-Z _ \ 0x80-0xff */
1140static const uint32_t valid_chars[8] = {
1141 0x00000000,
1142 0x03ff0000,
1143 0x97fffffe,
1144 0x07fffffe,
1145 0xffffffff,
1146 0xffffffff,
1147 0xffffffff,
1148 0xffffffff,
1149};
1150
1152 for (size_t i = 0; i < ZSTR_LEN(name); i++) {
1153 unsigned char c = ZSTR_VAL(name)[i];
1154 if (!ZEND_BIT_TEST(valid_chars, c)) {
1155 return 0;
1156 }
1157 }
1158 return 1;
1159}
1160
1162{
1163 zend_class_entry *ce = NULL;
1164 zval *zv;
1165 zend_string *lc_name;
1166 zend_string *autoload_name;
1167 uint32_t ce_cache = 0;
1168
1170 ce_cache = GC_REFCOUNT(name);
1171 ce = GET_CE_CACHE(ce_cache);
1172 if (EXPECTED(ce)) {
1173 return ce;
1174 }
1175 }
1176
1177 if (key) {
1178 lc_name = key;
1179 } else {
1180 if (!ZSTR_LEN(name)) {
1181 return NULL;
1182 }
1183
1184 if (ZSTR_VAL(name)[0] == '\\') {
1185 lc_name = zend_string_alloc(ZSTR_LEN(name) - 1, 0);
1187 } else {
1188 lc_name = zend_string_tolower(name);
1189 }
1190 }
1191
1192 zv = zend_hash_find(EG(class_table), lc_name);
1193 if (zv) {
1194 if (!key) {
1195 zend_string_release_ex(lc_name, 0);
1196 }
1197 ce = (zend_class_entry*)Z_PTR_P(zv);
1198 if (UNEXPECTED(!(ce->ce_flags & ZEND_ACC_LINKED))) {
1202 if (!CG(unlinked_uses)) {
1203 ALLOC_HASHTABLE(CG(unlinked_uses));
1204 zend_hash_init(CG(unlinked_uses), 0, NULL, NULL, 0);
1205 }
1206 zend_hash_index_add_empty_element(CG(unlinked_uses), (zend_long)(uintptr_t)ce);
1207 return ce;
1208 }
1209 return NULL;
1210 }
1211 /* Don't populate CE_CACHE for mutable classes during compilation.
1212 * The class may be freed while persisting. */
1213 if (ce_cache &&
1214 (!CG(in_compilation) || (ce->ce_flags & ZEND_ACC_IMMUTABLE))) {
1215 SET_CE_CACHE(ce_cache, ce);
1216 }
1217 return ce;
1218 }
1219
1220 /* The compiler is not-reentrant. Make sure we autoload only during run-time. */
1222 if (!key) {
1223 zend_string_release_ex(lc_name, 0);
1224 }
1225 return NULL;
1226 }
1227
1228 if (!zend_autoload) {
1229 if (!key) {
1230 zend_string_release_ex(lc_name, 0);
1231 }
1232 return NULL;
1233 }
1234
1235 /* Verify class name before passing it to the autoloader. */
1237 zend_string_release_ex(lc_name, 0);
1238 return NULL;
1239 }
1240
1241 if (EG(in_autoload) == NULL) {
1242 ALLOC_HASHTABLE(EG(in_autoload));
1243 zend_hash_init(EG(in_autoload), 8, NULL, NULL, 0);
1244 }
1245
1246 if (zend_hash_add_empty_element(EG(in_autoload), lc_name) == NULL) {
1247 if (!key) {
1248 zend_string_release_ex(lc_name, 0);
1249 }
1250 return NULL;
1251 }
1252
1253 if (ZSTR_VAL(name)[0] == '\\') {
1254 autoload_name = zend_string_init(ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1, 0);
1255 } else {
1256 autoload_name = zend_string_copy(name);
1257 }
1258
1259 zend_string *previous_filename = EG(filename_override);
1260 zend_long previous_lineno = EG(lineno_override);
1261 EG(filename_override) = NULL;
1262 EG(lineno_override) = -1;
1264 ce = zend_autoload(autoload_name, lc_name);
1266 EG(filename_override) = previous_filename;
1267 EG(lineno_override) = previous_lineno;
1268
1269 zend_string_release_ex(autoload_name, 0);
1270 zend_hash_del(EG(in_autoload), lc_name);
1271
1272 if (!key) {
1273 zend_string_release_ex(lc_name, 0);
1274 }
1275 if (ce) {
1276 ZEND_ASSERT(!CG(in_compilation));
1277 if (ce_cache) {
1278 SET_CE_CACHE(ce_cache, ce);
1279 }
1280 }
1281 return ce;
1282}
1283/* }}} */
1284
1289/* }}} */
1290
1292{
1293 while (ex) {
1294 if (Z_TYPE(ex->This) == IS_OBJECT) {
1295 return Z_OBJCE(ex->This);
1296 } else if (Z_CE(ex->This)) {
1297 return Z_CE(ex->This);
1298 } else if (ex->func) {
1299 if (ex->func->type != ZEND_INTERNAL_FUNCTION || ex->func->common.scope) {
1300 return NULL;
1301 }
1302 }
1303 ex = ex->prev_execute_data;
1304 }
1305 return NULL;
1306}
1307/* }}} */
1308
1310{
1311 while (ex) {
1312 if (Z_TYPE(ex->This) == IS_OBJECT) {
1313 return Z_OBJ(ex->This);
1314 } else if (ex->func) {
1315 if (ex->func->type != ZEND_INTERNAL_FUNCTION || ex->func->common.scope) {
1316 return NULL;
1317 }
1318 }
1319 ex = ex->prev_execute_data;
1320 }
1321 return NULL;
1322}
1323/* }}} */
1324
1325ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */
1326{
1328 uint32_t original_compiler_options;
1330 zend_string *code_str;
1331
1332 if (retval_ptr) {
1333 code_str = zend_string_concat3(
1334 "return ", sizeof("return ")-1, str, str_len, ";", sizeof(";")-1);
1335 } else {
1336 code_str = zend_string_init(str, str_len, 0);
1337 }
1338
1339 /*printf("Evaluating '%s'\n", pv.value.str.val);*/
1340
1341 original_compiler_options = CG(compiler_options);
1342 CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL;
1344 CG(compiler_options) = original_compiler_options;
1345
1346 if (new_op_array) {
1347 zval local_retval;
1348
1349 EG(no_extensions)=1;
1350
1352
1353 zend_try {
1354 ZVAL_UNDEF(&local_retval);
1355 zend_execute(new_op_array, &local_retval);
1356 } zend_catch {
1359 zend_bailout();
1360 } zend_end_try();
1361
1362 if (Z_TYPE(local_retval) != IS_UNDEF) {
1363 if (retval_ptr) {
1364 ZVAL_COPY_VALUE(retval_ptr, &local_retval);
1365 } else {
1366 zval_ptr_dtor(&local_retval);
1367 }
1368 } else {
1369 if (retval_ptr) {
1371 }
1372 }
1373
1374 EG(no_extensions)=0;
1378 retval = SUCCESS;
1379 } else {
1380 retval = FAILURE;
1381 }
1382 zend_string_release(code_str);
1383 return retval;
1384}
1385/* }}} */
1386
1387ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */
1388{
1389 return zend_eval_stringl(str, strlen(str), retval_ptr, string_name);
1390}
1391/* }}} */
1392
1393ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */
1394{
1396
1397 result = zend_eval_stringl(str, str_len, retval_ptr, string_name);
1398 if (handle_exceptions && EG(exception)) {
1400 }
1401 return result;
1402}
1403/* }}} */
1404
1405ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */
1406{
1407 return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions);
1408}
1409/* }}} */
1410
1411static void zend_set_timeout_ex(zend_long seconds, bool reset_signals);
1412
1414{
1415#if defined(PHP_WIN32)
1416# ifndef ZTS
1417 /* No action is needed if we're timed out because zero seconds are
1418 just ignored. Also, the hard timeout needs to be respected. If the
1419 timer is not restarted properly, it could hang in the shutdown
1420 function. */
1421 if (EG(hard_timeout) > 0) {
1422 zend_atomic_bool_store_ex(&EG(timed_out), false);
1423 zend_set_timeout_ex(EG(hard_timeout), 1);
1424 /* XXX Abused, introduce an additional flag if the value needs to be kept. */
1425 EG(hard_timeout) = 0;
1426 }
1427# endif
1428#else
1429 zend_atomic_bool_store_ex(&EG(timed_out), false);
1430 zend_set_timeout_ex(0, 1);
1431#endif
1432
1433 zend_error_noreturn(E_ERROR, "Maximum execution time of " ZEND_LONG_FMT " second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
1434}
1435/* }}} */
1436
1437#ifndef ZEND_WIN32
1438# ifdef ZEND_MAX_EXECUTION_TIMERS
1439static void zend_timeout_handler(int dummy, siginfo_t *si, void *uc) /* {{{ */
1440{
1441#ifdef ZTS
1442 if (!tsrm_is_managed_thread()) {
1443 fprintf(stderr, "zend_timeout_handler() called in a thread not managed by PHP. The expected signal handler will not be called. This is probably a bug.\n");
1444
1445 return;
1446 }
1447#endif
1448
1449 if (si->si_value.sival_ptr != &EG(max_execution_timer_timer)) {
1450#ifdef MAX_EXECUTION_TIMERS_DEBUG
1451 fprintf(stderr, "Executing previous handler (if set) for unexpected signal SIGRTMIN received on thread %d\n", (pid_t) syscall(SYS_gettid));
1452#endif
1453
1454 if (EG(oldact).sa_sigaction) {
1455 EG(oldact).sa_sigaction(dummy, si, uc);
1456
1457 return;
1458 }
1459 if (EG(oldact).sa_handler) EG(oldact).sa_handler(dummy);
1460
1461 return;
1462 }
1463# else
1464static void zend_timeout_handler(int dummy) /* {{{ */
1465{
1466# endif
1467#ifdef ZTS
1468 if (!tsrm_is_managed_thread()) {
1469 fprintf(stderr, "zend_timeout_handler() called in a thread not managed by PHP. The expected signal handler will not be called. This is probably a bug.\n");
1470
1471 return;
1472 }
1473#else
1474 if (zend_atomic_bool_load_ex(&EG(timed_out))) {
1475 /* Die on hard timeout */
1476 const char *error_filename = NULL;
1477 uint32_t error_lineno = 0;
1478 char log_buffer[2048];
1479 int output_len = 0;
1480
1481 if (zend_is_compiling()) {
1482 error_filename = ZSTR_VAL(zend_get_compiled_filename());
1483 error_lineno = zend_get_compiled_lineno();
1484 } else if (zend_is_executing()) {
1485 error_filename = zend_get_executed_filename();
1486 if (error_filename[0] == '[') { /* [no active file] */
1487 error_filename = NULL;
1488 error_lineno = 0;
1489 } else {
1490 error_lineno = zend_get_executed_lineno();
1491 }
1492 }
1493 if (!error_filename) {
1494 error_filename = "Unknown";
1495 }
1496
1497 output_len = snprintf(log_buffer, sizeof(log_buffer), "\nFatal error: Maximum execution time of " ZEND_LONG_FMT "+" ZEND_LONG_FMT " seconds exceeded (terminated) in %s on line %d\n", EG(timeout_seconds), EG(hard_timeout), error_filename, error_lineno);
1498 if (output_len > 0) {
1499 zend_quiet_write(2, log_buffer, MIN(output_len, sizeof(log_buffer)));
1500 }
1501 _exit(124);
1502 }
1503#endif
1504
1505 if (zend_on_timeout) {
1506 zend_on_timeout(EG(timeout_seconds));
1507 }
1508
1509 zend_atomic_bool_store_ex(&EG(timed_out), true);
1510 zend_atomic_bool_store_ex(&EG(vm_interrupt), true);
1511
1512#ifndef ZTS
1513 if (EG(hard_timeout) > 0) {
1514 /* Set hard timeout */
1515 zend_set_timeout_ex(EG(hard_timeout), 1);
1516 }
1517#endif
1518}
1519/* }}} */
1520#endif
1521
1522#ifdef ZEND_WIN32
1523VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out)
1524{
1526
1527 /* The doc states it'll be always true, however it theoretically
1528 could be FALSE when the thread was signaled. */
1529 if (!timed_out) {
1530 return;
1531 }
1532
1533 eg = (zend_executor_globals *)arg;
1534 zend_atomic_bool_store_ex(&eg->timed_out, true);
1535 zend_atomic_bool_store_ex(&eg->vm_interrupt, true);
1536}
1537#endif
1538
1539/* This one doesn't exists on QNX */
1540#ifndef SIGPROF
1541#define SIGPROF 27
1542#endif
1543
1544static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
1545{
1546#ifdef ZEND_WIN32
1548
1549 if (!seconds) {
1550 return;
1551 }
1552
1553 /* Don't use ChangeTimerQueueTimer() as it will not restart an expired
1554 * timer, so we could end up with just an ignored timeout. Instead
1555 * delete and recreate. */
1556 if (NULL != tq_timer) {
1557 if (!DeleteTimerQueueTimer(NULL, tq_timer, INVALID_HANDLE_VALUE)) {
1558 tq_timer = NULL;
1559 zend_error_noreturn(E_ERROR, "Could not delete queued timer");
1560 return;
1561 }
1562 tq_timer = NULL;
1563 }
1564
1565 /* XXX passing NULL means the default timer queue provided by the system is used */
1566 eg = ZEND_MODULE_GLOBALS_BULK(executor);
1567 if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)eg, seconds*1000, 0, WT_EXECUTEONLYONCE)) {
1568 tq_timer = NULL;
1569 zend_error_noreturn(E_ERROR, "Could not queue new timer");
1570 return;
1571 }
1572#elif defined(ZEND_MAX_EXECUTION_TIMERS)
1574
1575 if (reset_signals) {
1576 sigset_t sigset;
1577 struct sigaction act;
1578
1579 act.sa_sigaction = zend_timeout_handler;
1580 sigemptyset(&act.sa_mask);
1581 act.sa_flags = SA_ONSTACK | SA_SIGINFO;
1582 sigaction(SIGRTMIN, &act, NULL);
1583 sigemptyset(&sigset);
1584 sigaddset(&sigset, SIGRTMIN);
1585 sigprocmask(SIG_UNBLOCK, &sigset, NULL);
1586 }
1587#elif defined(HAVE_SETITIMER)
1588 {
1589 struct itimerval t_r; /* timeout requested */
1590 int signo;
1591
1592 // Prevent EINVAL error
1593 if (seconds < 0 || seconds > 999999999) {
1594 seconds = 0;
1595 }
1596
1597 if(seconds) {
1598 t_r.it_value.tv_sec = seconds;
1599 t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;
1600
1601# if defined(__CYGWIN__) || defined(__PASE__) || (defined(__aarch64__) && defined(__APPLE__))
1602 // ITIMER_PROF is broken in Apple Silicon system with MacOS >= 14
1603 // See https://openradar.appspot.com/radar?id=5583058442911744.
1604 setitimer(ITIMER_REAL, &t_r, NULL);
1605 }
1606 signo = SIGALRM;
1607# else
1608 setitimer(ITIMER_PROF, &t_r, NULL);
1609 }
1610 signo = SIGPROF;
1611# endif
1612
1613 if (reset_signals) {
1614# ifdef ZEND_SIGNALS
1615 zend_signal(signo, zend_timeout_handler);
1616# else
1617 sigset_t sigset;
1618# ifdef HAVE_SIGACTION
1619 struct sigaction act;
1620
1621 act.sa_handler = zend_timeout_handler;
1622 sigemptyset(&act.sa_mask);
1623 act.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_NODEFER;
1624 sigaction(signo, &act, NULL);
1625# else
1626 signal(signo, zend_timeout_handler);
1627# endif /* HAVE_SIGACTION */
1628 sigemptyset(&sigset);
1629 sigaddset(&sigset, signo);
1630 sigprocmask(SIG_UNBLOCK, &sigset, NULL);
1631# endif /* ZEND_SIGNALS */
1632 }
1633 }
1634#endif /* HAVE_SETITIMER */
1635}
1636/* }}} */
1637
1638void zend_set_timeout(zend_long seconds, bool reset_signals) /* {{{ */
1639{
1640
1641 EG(timeout_seconds) = seconds;
1642 zend_set_timeout_ex(seconds, reset_signals);
1643 zend_atomic_bool_store_ex(&EG(timed_out), false);
1644}
1645/* }}} */
1646
1647void zend_unset_timeout(void) /* {{{ */
1648{
1649#ifdef ZEND_WIN32
1650 if (NULL != tq_timer) {
1651 if (!DeleteTimerQueueTimer(NULL, tq_timer, INVALID_HANDLE_VALUE)) {
1652 zend_atomic_bool_store_ex(&EG(timed_out), false);
1653 tq_timer = NULL;
1654 zend_error_noreturn(E_ERROR, "Could not delete queued timer");
1655 return;
1656 }
1657 tq_timer = NULL;
1658 }
1659#elif defined(ZEND_MAX_EXECUTION_TIMERS)
1661#elif defined(HAVE_SETITIMER)
1662 if (EG(timeout_seconds)) {
1663 struct itimerval no_timeout;
1664
1665 no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
1666
1667# if defined(__CYGWIN__) || defined(__PASE__) || (defined(__aarch64__) && defined(__APPLE__))
1668 setitimer(ITIMER_REAL, &no_timeout, NULL);
1669# else
1670 setitimer(ITIMER_PROF, &no_timeout, NULL);
1671# endif
1672 }
1673#endif
1674 zend_atomic_bool_store_ex(&EG(timed_out), false);
1675}
1676/* }}} */
1677
1678static ZEND_COLD void report_class_fetch_error(zend_string *class_name, uint32_t fetch_type)
1679{
1680 if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
1681 return;
1682 }
1683
1684 if (EG(exception)) {
1685 if (!(fetch_type & ZEND_FETCH_CLASS_EXCEPTION)) {
1686 zend_exception_uncaught_error("During class fetch");
1687 }
1688 return;
1689 }
1690
1691 if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
1692 zend_throw_or_error(fetch_type, NULL, "Interface \"%s\" not found", ZSTR_VAL(class_name));
1693 } else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
1694 zend_throw_or_error(fetch_type, NULL, "Trait \"%s\" not found", ZSTR_VAL(class_name));
1695 } else {
1696 zend_throw_or_error(fetch_type, NULL, "Class \"%s\" not found", ZSTR_VAL(class_name));
1697 }
1698}
1699
1700zend_class_entry *zend_fetch_class(zend_string *class_name, uint32_t fetch_type) /* {{{ */
1701{
1702 zend_class_entry *ce, *scope;
1703 uint32_t fetch_sub_type = fetch_type & ZEND_FETCH_CLASS_MASK;
1704
1705check_fetch_type:
1706 switch (fetch_sub_type) {
1709 if (UNEXPECTED(!scope)) {
1710 zend_throw_or_error(fetch_type, NULL, "Cannot access \"self\" when no class scope is active");
1711 }
1712 return scope;
1715 if (UNEXPECTED(!scope)) {
1716 zend_throw_or_error(fetch_type, NULL, "Cannot access \"parent\" when no class scope is active");
1717 return NULL;
1718 }
1719 if (UNEXPECTED(!scope->parent)) {
1720 zend_throw_or_error(fetch_type, NULL, "Cannot access \"parent\" when current class scope has no parent");
1721 }
1722 return scope->parent;
1724 ce = zend_get_called_scope(EG(current_execute_data));
1725 if (UNEXPECTED(!ce)) {
1726 zend_throw_or_error(fetch_type, NULL, "Cannot access \"static\" when no class scope is active");
1727 return NULL;
1728 }
1729 return ce;
1730 case ZEND_FETCH_CLASS_AUTO: {
1731 fetch_sub_type = zend_get_class_fetch_type(class_name);
1732 if (UNEXPECTED(fetch_sub_type != ZEND_FETCH_CLASS_DEFAULT)) {
1733 goto check_fetch_type;
1734 }
1735 }
1736 break;
1737 }
1738
1739 ce = zend_lookup_class_ex(class_name, NULL, fetch_type);
1740 if (!ce) {
1741 report_class_fetch_error(class_name, fetch_type);
1742 return NULL;
1743 }
1744 return ce;
1745}
1746/* }}} */
1747
1749 zend_string *class_name, uint32_t fetch_type, zend_class_entry *scope)
1750{
1751 zend_class_entry *ce;
1752 switch (fetch_type & ZEND_FETCH_CLASS_MASK) {
1754 if (UNEXPECTED(!scope)) {
1755 zend_throw_or_error(fetch_type, NULL, "Cannot access \"self\" when no class scope is active");
1756 }
1757 return scope;
1759 if (UNEXPECTED(!scope)) {
1760 zend_throw_or_error(fetch_type, NULL, "Cannot access \"parent\" when no class scope is active");
1761 return NULL;
1762 }
1763 if (UNEXPECTED(!scope->parent)) {
1764 zend_throw_or_error(fetch_type, NULL, "Cannot access \"parent\" when current class scope has no parent");
1765 }
1766 return scope->parent;
1767 case 0:
1768 break;
1769 /* Other fetch types are not supported by this function. */
1771 }
1772
1773 ce = zend_lookup_class_ex(class_name, NULL, fetch_type);
1774 if (!ce) {
1775 report_class_fetch_error(class_name, fetch_type);
1776 return NULL;
1777 }
1778 return ce;
1779}
1780
1781zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string *key, uint32_t fetch_type) /* {{{ */
1782{
1783 zend_class_entry *ce = zend_lookup_class_ex(class_name, key, fetch_type);
1784 if (!ce) {
1785 report_class_fetch_error(class_name, fetch_type);
1786 return NULL;
1787 }
1788 return ce;
1789}
1790/* }}} */
1791
1793{
1794 return zend_hash_del_ind(&EG(symbol_table), name);
1795}
1796/* }}} */
1797
1799{
1801 zend_array *symbol_table;
1802
1803 /* Search for last called user function */
1804 ex = EG(current_execute_data);
1805 while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->common.type))) {
1806 ex = ex->prev_execute_data;
1807 }
1808 if (!ex) {
1809 return NULL;
1810 }
1812 return ex->symbol_table;
1813 }
1814
1816 if (EG(symtable_cache_ptr) > EG(symtable_cache)) {
1817 symbol_table = ex->symbol_table = *(--EG(symtable_cache_ptr));
1818 if (!ex->func->op_array.last_var) {
1819 return symbol_table;
1820 }
1821 zend_hash_extend(symbol_table, ex->func->op_array.last_var, 0);
1822 } else {
1823 symbol_table = ex->symbol_table = zend_new_array(ex->func->op_array.last_var);
1824 if (!ex->func->op_array.last_var) {
1825 return symbol_table;
1826 }
1827 zend_hash_real_init_mixed(symbol_table);
1828 /*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/
1829 }
1830 if (EXPECTED(ex->func->op_array.last_var)) {
1831 zend_string **str = ex->func->op_array.vars;
1832 zend_string **end = str + ex->func->op_array.last_var;
1833 zval *var = ZEND_CALL_VAR_NUM(ex, 0);
1834
1835 do {
1836 _zend_hash_append_ind(symbol_table, *str, var);
1837 str++;
1838 var++;
1839 } while (str != end);
1840 }
1841 return symbol_table;
1842}
1843/* }}} */
1844
1846{
1847 zend_op_array *op_array = &execute_data->func->op_array;
1848 HashTable *ht = execute_data->symbol_table;
1849
1850 /* copy real values from symbol table into CV slots and create
1851 INDIRECT references to CV in symbol table */
1852 if (EXPECTED(op_array->last_var)) {
1853 zend_string **str = op_array->vars;
1854 zend_string **end = str + op_array->last_var;
1855 zval *var = EX_VAR_NUM(0);
1856
1857 do {
1859
1860 if (zv) {
1861 if (Z_TYPE_P(zv) == IS_INDIRECT) {
1862 zval *val = Z_INDIRECT_P(zv);
1863
1864 ZVAL_COPY_VALUE(var, val);
1865 } else {
1866 ZVAL_COPY_VALUE(var, zv);
1867 }
1868 } else {
1869 ZVAL_UNDEF(var);
1870 zv = zend_hash_add_new(ht, *str, var);
1871 }
1872 ZVAL_INDIRECT(zv, var);
1873 str++;
1874 var++;
1875 } while (str != end);
1876 }
1877}
1878/* }}} */
1879
1881{
1882 zend_op_array *op_array = &execute_data->func->op_array;
1883 HashTable *ht = execute_data->symbol_table;
1884
1885 /* copy real values from CV slots into symbol table */
1886 if (EXPECTED(op_array->last_var)) {
1887 zend_string **str = op_array->vars;
1888 zend_string **end = str + op_array->last_var;
1889 zval *var = EX_VAR_NUM(0);
1890
1891 do {
1892 if (Z_TYPE_P(var) == IS_UNDEF) {
1893 zend_hash_del(ht, *str);
1894 } else {
1895 zend_hash_update(ht, *str, var);
1896 ZVAL_UNDEF(var);
1897 }
1898 str++;
1899 var++;
1900 } while (str != end);
1901 }
1902}
1903/* }}} */
1904
1906{
1907 zend_execute_data *execute_data = EG(current_execute_data);
1908
1909 while (execute_data && (!execute_data->func || !ZEND_USER_CODE(execute_data->func->common.type))) {
1910 execute_data = execute_data->prev_execute_data;
1911 }
1912
1913 if (execute_data) {
1915 zend_ulong h = zend_string_hash_val(name);
1916 zend_op_array *op_array = &execute_data->func->op_array;
1917
1918 if (EXPECTED(op_array->last_var)) {
1919 zend_string **str = op_array->vars;
1920 zend_string **end = str + op_array->last_var;
1921
1922 do {
1923 if (ZSTR_H(*str) == h &&
1924 zend_string_equal_content(*str, name)) {
1925 zval *var = EX_VAR_NUM(str - op_array->vars);
1926 ZVAL_COPY_VALUE(var, value);
1927 return SUCCESS;
1928 }
1929 str++;
1930 } while (str != end);
1931 }
1932 if (force) {
1933 zend_array *symbol_table = zend_rebuild_symbol_table();
1934 if (symbol_table) {
1935 zend_hash_update(symbol_table, name, value);
1936 return SUCCESS;
1937 }
1938 }
1939 } else {
1941 return SUCCESS;
1942 }
1943 }
1944 return FAILURE;
1945}
1946/* }}} */
1947
1948ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval *value, bool force) /* {{{ */
1949{
1950 zend_execute_data *execute_data = EG(current_execute_data);
1951
1952 while (execute_data && (!execute_data->func || !ZEND_USER_CODE(execute_data->func->common.type))) {
1953 execute_data = execute_data->prev_execute_data;
1954 }
1955
1956 if (execute_data) {
1959 zend_op_array *op_array = &execute_data->func->op_array;
1960 if (EXPECTED(op_array->last_var)) {
1961 zend_string **str = op_array->vars;
1962 zend_string **end = str + op_array->last_var;
1963
1964 do {
1965 if (ZSTR_H(*str) == h &&
1966 zend_string_equals_cstr(*str, name, len)) {
1967 zval *var = EX_VAR_NUM(str - op_array->vars);
1968 zval_ptr_dtor(var);
1969 ZVAL_COPY_VALUE(var, value);
1970 return SUCCESS;
1971 }
1972 str++;
1973 } while (str != end);
1974 }
1975 if (force) {
1976 zend_array *symbol_table = zend_rebuild_symbol_table();
1977 if (symbol_table) {
1978 zend_hash_str_update(symbol_table, name, len, value);
1979 return SUCCESS;
1980 }
1981 }
1982 } else {
1984 return SUCCESS;
1985 }
1986 }
1987 return FAILURE;
1988}
1989/* }}} */
size_t len
Definition apprentice.c:174
bool exception
Definition assert.c:30
fprintf($stream, string $format, mixed ... $values)
fflush($stream)
error($message)
Definition ext_skel.php:22
zval * zv
Definition ffi.c:3975
zval * arg
Definition ffi.c:3975
ffi symbols
Definition ffi.c:3114
memset(ptr, 0, type->size)
zval * val
Definition ffi.c:4262
HashTable * ht
Definition ffi.c:4838
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
const SIG_UNBLOCK
const SIGSEGV
const SIG_DFL
const SIGRTMIN
unsigned const char * end
Definition php_ffi.h:51
#define CALLBACK(FOR)
php_output_handler * active
Definition php_output.h:140
unsigned char key[REFLECTION_KEY_LEN]
zend_object * ex
p
Definition session.c:1105
#define SIGALRM
Definition signal.h:8
zend_ast_attr attr
Definition zend_ast.h:188
zend_ast_kind kind
Definition zend_ast.h:187
zend_class_entry * ce
HashTable constants_table
Definition zend.h:165
HashTable * backed_enum_table
Definition zend.h:222
uint32_t num_hooked_props
Definition zend.h:207
HashTable properties_info
Definition zend.h:164
zend_string * name
Definition zend.h:149
uint32_t ce_flags
Definition zend.h:156
int default_properties_count
Definition zend.h:158
char type
Definition zend.h:148
int default_static_members_count
Definition zend.h:159
zval * default_properties_table
Definition zend.h:160
HashTable function_table
Definition zend.h:163
zend_string * name
zend_atomic_bool timed_out
zend_atomic_bool vm_interrupt
activate_func_t activate
deactivate_func_t deactivate
zend_function * function_handler
Definition zend_API.h:60
zend_class_entry * called_scope
Definition zend_API.h:62
zend_object * object
Definition zend_API.h:63
HashTable * named_params
Definition zend_API.h:56
uint32_t param_count
Definition zend_API.h:51
zend_object * object
Definition zend_API.h:50
zend_string ** vars
uint8_t opcode
struct timeval it_value
Definition time.h:28
struct timeval it_interval
Definition time.h:27
PHPAPI int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
#define ITIMER_PROF
Definition time.h:42
#define ITIMER_REAL
Definition time.h:39
zend_class_entry * scope
zend_string * function_name
struct _zend_function::@236135173067030250234125302313220025134003177336 common
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format,...)
Definition zend.c:1703
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
Definition zend.c:1666
void(* zend_on_timeout)(int seconds)
Definition zend.c:102
ZEND_API size_t zend_vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap)
Definition zend.c:283
ZEND_API void(* zend_interrupt_function)(zend_execute_data *execute_data)
Definition zend.c:89
#define zend_catch
Definition zend.h:277
@ EH_NORMAL
Definition zend.h:432
#define zend_try
Definition zend.h:270
#define zend_end_try()
Definition zend.h:280
#define zend_bailout()
Definition zend.h:268
ZEND_API zend_string * zend_get_callable_name_ex(zval *callable, zend_object *object)
Definition zend_API.c:4106
ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error)
Definition zend_API.c:4271
ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc)
Definition zend_API.c:3845
ZEND_API const zend_fcall_info empty_fcall_info
ZEND_API const zend_fcall_info_cache empty_fcall_info_cache
struct _zend_fcall_info_cache zend_fcall_info_cache
#define IS_CALLABLE_SUPPRESS_DEPRECATIONS
Definition zend_API.h:412
struct _zend_fcall_info zend_fcall_info
#define ZEND_MODULE_GLOBALS_BULK(module_name)
Definition zend_API.h:275
ZEND_API bool is_zend_mm(void)
#define efree_size(ptr, size)
Definition zend_alloc.h:138
#define efree(ptr)
Definition zend_alloc.h:155
#define FREE_HASHTABLE(ht)
Definition zend_alloc.h:234
#define ALLOC_HASHTABLE(ht)
Definition zend_alloc.h:231
ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_ex(zval *result, zend_ast *ast, zend_class_entry *scope, bool *short_circuited_ptr, zend_ast_evaluate_ctx *ctx)
Definition zend_ast.c:544
@ ZEND_AST_CONSTANT
Definition zend_ast.h:37
#define ZEND_ATOMIC_BOOL_INIT(obj, desired)
struct _zval_struct zval
strlen(string $string)
zend_string_release_ex(func->internal_function.function_name, 0)
execute_data func
#define ZEND_CLOSURE_OBJECT(op_array)
uint32_t zend_get_class_fetch_type(const zend_string *name)
ZEND_API bool zend_is_compiling(void)
ZEND_API zend_op_array *(* zend_compile_string)(zend_string *source_string, const char *filename, zend_compile_position position)
ZEND_API int zend_get_compiled_lineno(void)
ZEND_API zend_string * zend_get_compiled_filename(void)
ZEND_API zend_string * zend_create_member_string(zend_string *class_name, zend_string *member_name)
#define ZEND_PROPERTY_HOOK_COUNT
#define ZEND_FETCH_CLASS_SELF
#define ZEND_CALL_CLOSURE
struct _zend_op zend_op
#define ZEND_FETCH_CLASS_AUTO
#define ZEND_USER_CODE(type)
#define EX_VAR_NUM(n)
#define ZEND_CALL_TOP_FUNCTION
#define ZEND_ACC_FAKE_CLOSURE
#define ZEND_FETCH_CLASS_MASK
#define ZEND_ACC_IMMUTABLE
ZEND_API void destroy_op_array(zend_op_array *op_array)
#define ZEND_FETCH_CLASS_ALLOW_NEARLY_LINKED
#define ZEND_HAS_STATIC_IN_METHODS
#define ZEND_INTERNAL_FUNCTION
#define ZEND_COMPILE_DEFAULT_FOR_EVAL
#define ZEND_ACC_LINKED
#define ZEND_FETCH_CLASS_TRAIT
#define ZEND_ACC_NEARLY_LINKED
#define ZEND_FETCH_CLASS_INTERFACE
#define ZEND_FETCH_CLASS_NO_AUTOLOAD
#define ZEND_ACC_USER_ARG_INFO
#define EX(element)
#define ZEND_USER_FUNCTION
#define EX_CALL_INFO()
#define ZEND_CALL_HAS_SYMBOL_TABLE
#define ZEND_ACC_CALL_VIA_TRAMPOLINE
struct _zend_op_array zend_op_array
#define ZEND_CALL_HAS_THIS
ZEND_API void destroy_zend_class(zval *zv)
struct _zend_class_constant zend_class_constant
struct _zend_property_info zend_property_info
#define ZEND_CALL_HAS_EXTRA_NAMED_PARAMS
ZEND_API void zend_destroy_static_vars(zend_op_array *op_array)
#define ZEND_FETCH_CLASS_STATIC
#define ZEND_FETCH_CLASS_DEFAULT
struct _zend_internal_arg_info zend_internal_arg_info
#define ZEND_CALL_NUM_ARGS(call)
#define ZEND_ACC_STATIC
#define ZEND_FETCH_CLASS_EXCEPTION
#define ZEND_CALL_INFO(call)
#define ZEND_FETCH_CLASS_PARENT
#define ZEND_ACC_HAS_RETURN_TYPE
@ ZEND_COMPILE_POSITION_AFTER_OPEN_TAG
#define ZEND_CALL_DYNAMIC
#define ZEND_USER_CLASS
#define ZEND_ADD_CALL_FLAG(call, flag)
#define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num)
#define ZEND_CALL_MAY_HAVE_UNDEF
ZEND_API void zend_cleanup_mutable_class_data(zend_class_entry *ce)
#define ZEND_FETCH_CLASS_ALLOW_UNLINKED
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
#define ZEND_INTERNAL_CLASS
#define ZEND_ACC_DEPRECATED
#define ZEND_CALL_RELEASE_THIS
#define ZEND_FETCH_CLASS_SILENT
#define ZEND_ACC_RETURN_REFERENCE
#define ARG_MAY_BE_SENT_BY_REF(zf, arg_num)
#define ZEND_ACC_CLOSURE
#define ZEND_CALL_VAR_NUM(call, n)
#define ZEND_CALL_ARG(call, n)
#define ZEND_CALL_FAKE_CLOSURE
#define ZEND_API
#define snprintf
ZEND_API zval * zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, uint32_t flags)
#define ZEND_CONSTANT_FLAGS(c)
#define CONST_PERSISTENT
struct _zend_constant zend_constant
#define E_ERROR
Definition zend_errors.h:23
#define E_WARNING
Definition zend_errors.h:24
#define E_CORE_ERROR
Definition zend_errors.h:27
ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception)
void zend_exception_restore(void)
void zend_exception_save(void)
ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severity)
ZEND_NORETURN void zend_exception_uncaught_error(const char *format,...)
ZEND_API void ZEND_FASTCALL zend_free_extra_named_params(zend_array *extra_named_params)
ZEND_API void zend_init_func_execute_data(zend_execute_data *ex, zend_op_array *op_array, zval *return_value)
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)
ZEND_API void zend_vm_stack_destroy(void)
ZEND_API void zend_vm_stack_init(void)
ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call)
ZEND_COLD void ZEND_FASTCALL zend_param_must_be_ref(const zend_function *func, uint32_t arg_num)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
zval *ZEND_FASTCALL zend_handle_named_arg(zend_execute_data **call_ptr, zend_string *arg_name, uint32_t *arg_num_ptr, void **cache_slot)
ZEND_API void(* zend_execute_ex)(zend_execute_data *execute_data)
ZEND_API void(* zend_execute_internal)(zend_execute_data *execute_data, zval *return_value)
ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value)
ZEND_API zend_class_entry *(* zend_autoload)(zend_string *name, zend_string *lc_name)
ZEND_API zend_class_entry * zend_get_called_scope(zend_execute_data *ex)
void init_executor(void)
ZEND_API zend_class_entry * zend_lookup_class(zend_string *name)
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_with_ctx(zval *p, zend_class_entry *scope, zend_ast_evaluate_ctx *ctx)
ZEND_API const char * get_function_arg_name(const zend_function *func, uint32_t arg_num)
ZEND_API const char * get_active_function_name(void)
ZEND_API zend_result ZEND_FASTCALL zval_update_constant(zval *pp)
ZEND_API void zend_call_known_instance_method_with_2_params(zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2)
void zend_set_timeout(zend_long seconds, bool reset_signals)
ZEND_API uint32_t zend_get_executed_lineno(void)
ZEND_API zend_class_entry * zend_get_executed_scope(void)
zend_class_entry * zend_fetch_class_by_name(zend_string *class_name, zend_string *key, uint32_t fetch_type)
ZEND_API zend_string * get_function_or_method_name(const zend_function *func)
ZEND_API const char * zend_get_executed_filename(void)
void shutdown_destructors(void)
void shutdown_executor(void)
ZEND_API void(* zend_execute_ex)(zend_execute_data *execute_data)
zend_class_entry * zend_fetch_class_with_scope(zend_string *class_name, uint32_t fetch_type, zend_class_entry *scope)
ZEND_API void(* zend_execute_internal)(zend_execute_data *execute_data, zval *return_value)
ZEND_API zend_object * zend_get_this_object(zend_execute_data *ex)
ZEND_API zend_result zend_call_method_if_exists(zend_object *object, zend_string *method_name, zval *retval, uint32_t param_count, zval *params)
ZEND_API bool zend_is_valid_class_name(zend_string *name)
ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data)
ZEND_API zend_string * zend_get_executed_filename_ex(void)
ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
ZEND_API const char * get_active_function_arg_name(uint32_t arg_num)
ZEND_API const char * get_active_class_name(const char **space)
zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params)
ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name)
zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache)
ZEND_API bool zend_is_executing(void)
ZEND_API zend_class_entry *(* zend_autoload)(zend_string *name, zend_string *lc_name)
ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data)
#define SIGPROF
ZEND_API zend_result zend_set_local_var(zend_string *name, zval *value, bool force)
zend_class_entry * zend_fetch_class(zend_string *class_name, uint32_t fetch_type)
ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void)
void zend_unset_timeout(void)
ZEND_API zend_result zend_delete_global_variable(zend_string *name)
ZEND_API zend_array * zend_rebuild_symbol_table(void)
ZEND_API void zend_call_known_function(zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params)
ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval *value, bool force)
ZEND_API zend_string * get_active_function_or_method_name(void)
ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions)
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *p, zend_class_entry *scope)
ZEND_API zend_class_entry * zend_lookup_class_ex(zend_string *name, zend_string *key, uint32_t flags)
ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name)
ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions)
ZEND_API zend_function * zend_active_function_ex(zend_execute_data *execute_data)
ZEND_API zend_llist zend_extensions
struct _zend_extension zend_extension
void zend_fiber_init(void)
void zend_fiber_shutdown(void)
ZEND_API void zend_shutdown_fpu(void)
Definition zend_float.c:39
ZEND_API void zend_init_fpu(void)
Definition zend_float.c:23
union _zend_function zend_function
#define ZEND_OP_IS_FRAMELESS_ICALL(opcode)
#define ZEND_FLF_FUNC(opline)
ZEND_API int(* gc_collect_cycles)(void)
Definition zend_gc.c:245
#define SYMTABLE_CACHE_SIZE
#define EG_FLAGS_INITIAL
#define EG_FLAGS_IN_RESOURCE_SHUTDOWN
struct _zend_executor_globals zend_executor_globals
#define CG(v)
#define EG(v)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
Definition zend_hash.c:1727
ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func)
Definition zend_hash.c:2192
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h)
Definition zend_hash.c:1059
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update_ind(HashTable *ht, const char *str, size_t len, zval *pData)
Definition zend_hash.c:1038
ZEND_API zval *ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:1007
ZEND_API zval *ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key)
Definition zend_hash.c:2679
ZEND_API zval *ZEND_FASTCALL zend_hash_update_ind(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:1002
ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht)
Definition zend_hash.c:2015
ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed)
Definition zend_hash.c:396
ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key)
Definition zend_hash.c:1566
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
Definition zend_hash.c:1031
ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
Definition zend_hash.c:1808
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:997
ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht)
Definition zend_hash.c:338
ZEND_API zval *ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_string *key)
Definition zend_hash.c:1067
ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key)
Definition zend_hash.c:1534
ZEND_API zval *ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key)
Definition zend_hash.c:2668
ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed)
Definition zend_hash.c:435
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
Definition zend_hash.h:108
#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr)
Definition zend_hash.h:1326
#define ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1384
#define ZEND_HASH_MAP_REVERSE_FOREACH_VAL(ht, _val)
Definition zend_hash.h:1314
#define ZEND_HASH_APPLY_REMOVE
Definition zend_hash.h:147
#define zend_new_array(size)
Definition zend_hash.h:338
#define ZEND_HASH_APPLY_KEEP
Definition zend_hash.h:146
#define ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1166
int(* apply_func_t)(zval *pDest)
Definition zend_hash.h:150
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
#define ZEND_HASH_MAP_FOREACH_END_DEL()
Definition zend_hash.h:1276
void zend_lazy_objects_init(zend_lazy_objects_store *store)
void zend_lazy_objects_destroy(zend_lazy_objects_store *store)
void zend_close_rsrc_list(HashTable *ht)
Definition zend_list.c:215
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func)
Definition zend_llist.c:179
void(* llist_apply_func_t)(void *)
Definition zend_llist.h:35
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
#define ZEND_LONG_FMT
Definition zend_long.h:87
struct _zend_string zend_string
#define ZEND_MAP_PTR_GET(ptr)
#define ZEND_MAP_PTR_GET_IMM(ptr)
#define ZEND_MAP_PTR(ptr)
#define ZEND_MAP_PTR_SET(ptr, val)
#define zend_max_execution_timer_shutdown()
#define zend_max_execution_timer_settime(seconds)
#define zend_max_execution_timer_init()
ZEND_API void ZEND_FASTCALL zend_objects_store_destroy(zend_objects_store *objects)
ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_store *objects, bool fast_shutdown)
ZEND_API void ZEND_FASTCALL zend_objects_store_mark_destructed(zend_objects_store *objects)
ZEND_API void ZEND_FASTCALL zend_objects_store_call_destructors(zend_objects_store *objects)
ZEND_API void ZEND_FASTCALL zend_objects_store_init(zend_objects_store *objects, uint32_t init_size)
#define OBJ_RELEASE(obj)
#define ZEND_OBSERVER_FCALL_BEGIN(execute_data)
#define ZEND_OBSERVER_FCALL_END(execute_data, return_value)
ZEND_API char *ZEND_FASTCALL zend_str_tolower_copy(char *dest, const char *source, size_t length)
#define zend_quiet_write(...)
#define MIN(a, b)
#define EXPECTED(condition)
#define ZEND_FASTCALL
#define ZEND_ASSERT(c)
#define ZEND_BIT_TEST(bits, bit)
#define ZEND_COLD
#define EMPTY_SWITCH_DEFAULT_CASE()
#define UNEXPECTED(condition)
#define ZEND_NORETURN
struct _zend_array zend_array
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
#define zend_signal(signo, handler)
ZEND_API void zend_stack_destroy(zend_stack *stack)
Definition zend_stack.c:78
ZEND_API void zend_stack_init(zend_stack *stack, int size)
Definition zend_stack.c:25
ZEND_API void zend_stack_clean(zend_stack *stack, void(*func)(void *), bool free_elements)
Definition zend_stack.c:144
void zend_stream_shutdown(void)
ZEND_API zend_ulong ZEND_FASTCALL zend_hash_func(const char *str, size_t len)
Definition zend_string.c:60
ZEND_API zend_string * zend_string_concat3(const char *str1, size_t str1_len, const char *str2, size_t str2_len, const char *str3, size_t str3_len)
#define ZSTR_H(zstr)
Definition zend_string.h:70
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_INIT_LITERAL(s, persistent)
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define ZVAL_STR(z, s)
#define Z_ISREF_P(zval_p)
Definition zend_types.h:954
struct _zend_ast_ref zend_ast_ref
Definition zend_types.h:101
#define Z_TRY_ADDREF_P(pz)
#define ZVAL_UNDEF(z)
#define Z_REFVAL_P(zval_p)
#define IS_UNDEF
Definition zend_types.h:600
#define Z_ISUNDEF_P(zval_p)
Definition zend_types.h:957
#define ZVAL_NULL(z)
#define Z_CE(zval)
#define ZVAL_INDIRECT(z, v)
struct _zend_array HashTable
Definition zend_types.h:386
#define Z_OBJ_P(zval_p)
Definition zend_types.h:990
#define ZVAL_COPY_OR_DUP(z, v)
#define Z_PTR_P(zval_p)
#define ZVAL_NEW_REF(z, r)
#define GC_DELREF(p)
Definition zend_types.h:710
#define GC_FLAGS(p)
Definition zend_types.h:756
#define ZSTR_HAS_CE_CACHE(s)
Definition zend_types.h:841
#define GC_ADDREF(p)
Definition zend_types.h:709
#define ZSTR_VALID_CE_CACHE(s)
Definition zend_types.h:845
@ FAILURE
Definition zend_types.h:61
#define IS_OBJECT
Definition zend_types.h:608
#define ZVAL_COPY(z, v)
struct _zend_refcounted zend_refcounted
Definition zend_types.h:95
#define Z_INDIRECT_P(zval_p)
#define Z_AST_P(zval_p)
#define Z_REFCOUNT_P(pz)
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define IS_CONSTANT_AST
Definition zend_types.h:611
struct _HashTableIterator HashTableIterator
#define ZEND_TLS
Definition zend_types.h:84
#define GC_REFCOUNT(p)
Definition zend_types.h:707
#define Z_TYPE(zval)
Definition zend_types.h:659
#define IS_INDIRECT
Definition zend_types.h:623
struct _zend_ast zend_ast
Definition zend_types.h:102
struct _zend_execute_data zend_execute_data
Definition zend_types.h:91
#define ZVAL_ERROR(z)
#define Z_ASTVAL_P(zval_p)
#define ZVAL_COPY_VALUE(z, v)
#define GC_IMMUTABLE
Definition zend_types.h:780
#define GET_CE_CACHE(ce_cache)
Definition zend_types.h:857
#define Z_OBJCE(zval)
#define SET_CE_CACHE(ce_cache, ce)
Definition zend_types.h:860
#define Z_OBJ(zval)
Definition zend_types.h:989
ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
#define ZVAL_PTR_DTOR
zval retval
uint32_t call_info
new_op_array
zval * return_value
zend_property_info * prop_info
retval_ptr
uint32_t arg_num
zend_string * name
bool result
function(EX_VAR(opline->result.var))
execute_data
object
value
zend_execute_data * call
new_op_array scope
#define ZEND_HANDLE_EXCEPTION
void zend_weakrefs_shutdown(void)
void zend_weakrefs_init(void)