php-src/ext/zend_test/tests
Arnaud Le Blanc cb245411b0
Add runtime-enabled heap debugging capabilities (#18172)
Debugging memory corruption issues in production can be difficult when it's not possible to use a debug build or ASAN/MSAN/Valgrind (e.g. for performance reasons).

This change makes it possible to enable some basic heap debugging helpers without rebuilding PHP. This is controlled by the environment variable ZEND_MM_DEBUG. The env var takes a comma-separated list of parameters:

- poison_free=byte: Override freed blocks with the specified byte value (represented as a number)
- poison_alloc=byte: Override newly allocated blocks with the specified byte value (represented as a number)
- padding=bytes: Pad allocated blocks with the specified amount of bytes (if non-zero, a value >= 16 is recommended to not break alignments) 
- check_freelists_on_shutdown=0|1: Enable checking freelist consistency [1] on shutdown

Example:

    ZEND_MM_DEBUG=poison_free=0xbe,poison_alloc=0xeb,padding=16,check_freelists_on_shutdown=1 php ...

This is implemented by installing custom handlers when ZEND_MM_DEBUG is set.

This has zero overhead when ZEND_MM_DEBUG is not set. When ZEND_MM_DEBUG is set, the overhead is about 8.5% on the Symfony Demo benchmark.

Goals:

 - Crash earlier after a memory corruption, to extract a useful backtrace
 - Be usable in production with reasonable overhead
 - Having zero overhead when not enabled

Non-goals:

 - Replace debug builds, valgrind, ASAN, MSAN or other sanitizers

[1] https://github.com/php/php-src/pull/14054

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2025-03-31 17:24:42 +02:00
..
iterators adds failing test case for #12060 2023-09-05 10:23:22 +01:00
attribute-deprecated.phpt RFC: Add #[\Deprecated] Attribute (#11293) 2024-07-02 09:44:25 +02:00
attribute-internal-property.phpt releases property attributes of internal classes (#11980) 2023-08-24 16:07:00 +02:00
attribute-named-parameter.phpt gen_stub: Intern the parameter name string for named arguments in internal attributes (#14595) 2024-06-19 08:06:50 +02:00
attribute-promotion-parameter-only.phpt Properly deal with internal attributes used on promoted properties. 2022-11-03 14:29:22 +01:00
attribute-promotion-property-only.phpt Properly deal with internal attributes used on promoted properties. 2022-11-03 14:29:22 +01:00
attribute_arguments.phpt Add tests for function parameter attributes to ext/zend_test 2022-03-07 22:10:54 +01:00
attribute_hash_table_leak.phpt Add tests for function parameter attributes to ext/zend_test 2022-03-07 22:10:54 +01:00
class_constant_deprecated.phpt Add ReflectionClassConstant::isDeprecated() (#14086) 2024-04-30 17:26:27 +02:00
do_operation_not_cast.phpt RFC: Saner array_(sum|product)() (#10161) 2023-03-07 15:40:17 +00:00
doc_comment_internal_symbols1.phpt Implement "support doc comments for internal classes and functions" (#13266) 2024-02-25 08:41:31 +01:00
doc_comment_internal_symbols2.phpt Implement "support doc comments for internal classes and functions" (#13266) 2024-02-25 08:41:31 +01:00
execute_internal.phpt Add test, fix x86 JIT 2023-03-13 12:36:59 +01:00
fiber_test_01.phpt Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
fiber_test_02.phpt Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
fiber_test_03.phpt Reorganize zend_test and add custom fiber implementation tests (#7137) 2021-06-11 12:25:47 -05:00
fiber_test_04.phpt Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
fiber_test_05.phpt Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
fiber_test_06.phpt Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
fiber_test_07.phpt Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
gen_stub_test_01.phpt Fix GH-12558 Escape \N in generated stubs (#12562) 2023-10-31 10:06:56 +01:00
gen_stub_test_02.phpt Add support for generating namespaced constant 2023-02-23 10:05:30 +01:00
gen_stub_test_03.phpt Fix GH-9967 Add support for generating custom function, class const, and property attributes in stubs 2023-08-26 21:35:31 +02:00
get_function_or_method_name_01.inc Fix get_function_or_method_name when included file is scoped (#8467) 2022-05-03 21:34:01 +02:00
get_function_or_method_name_01.phpt Merge branch 'PHP-8.0' into PHP-8.1 2022-05-03 21:36:42 +02:00
gh8575.phpt Fix zend_test extension name (#13321) 2024-02-04 19:27:58 +01:00
gh9871.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
gh10370.tar Fix GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range (#10440) 2023-02-10 13:08:44 +01:00
gh10370_1.phpt Fix concurrent testing 2023-02-10 13:31:57 +01:00
gh10370_2.phpt Fix concurrent testing 2023-02-10 13:31:57 +01:00
gh10370_3.phpt Fix concurrent testing 2023-02-10 13:31:57 +01:00
gh10370_4.phpt Fix concurrent testing 2023-02-10 13:31:57 +01:00
gh10695_1.phpt Forward shutdown exceptions to user error handlers 2023-06-15 17:11:22 +02:00
gh10695_2.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
gh11078.phpt Fix GH-11078: PHP Fatal error triggers pointer being freed was not allocated and malloc: double free for ptr errors 2024-06-10 19:38:21 +02:00
gh11423.phpt Revert "Remove name field from the zend_constant struct (#10954)" 2023-07-17 22:32:41 +02:00
gh13970.phpt Delay #[Attribute] arg validation until runtime 2024-05-06 12:38:56 +02:00
gh14109.phpt Add test for GH-14109 2024-05-06 16:03:02 +02:00
gh14741.phpt Fix GH-14741: Segmentation fault in Zend/zend_types.h 2024-07-09 00:56:53 +02:00
gh16230.phpt [skip ci] Fix new closure dump syntax in test 2024-10-14 15:03:53 +02:00
gh16233.phpt Fixed GH-16233: Observer segfault when calling user function in internal function via trampoline 2024-10-07 17:16:43 +02:00
gh16266.phpt Fix GH-16266: _ZendTestClass::test() segfaults on named parameter 2024-10-21 19:43:33 +02:00
gh16294.phpt Fix segfault in zend_test_execute_internal() 2024-10-14 14:02:36 +02:00
gh16388.phpt Fix GH-16388: UB when freeing a cloned _ZendTestFiber 2024-10-12 22:48:11 +02:00
gh16414.phpt Fix GH-16414: zend_test.observer.observe_function_names may segfault 2024-10-20 12:11:08 +02:00
gh16514.phpt [skip ci] Fix overwritten observer ini setting for gh16514.phpt 2024-10-22 15:20:56 +02:00
gh16908.phpt Fix test expectation for PHP 8.3+ 2024-11-25 20:33:14 +01:00
gh17408.phpt Fix GH-17408: Assertion failure Zend/zend_exceptions.c 2025-01-21 08:20:38 +01:00
gh17797.phpt [skip ci] zend_test adding closing tags to newer tests 2025-02-23 13:23:26 +00:00
gh17899.phpt [skip ci] zend_test adding closing tags to newer tests 2025-02-23 13:23:26 +00:00
hash_fill_packed_nr_elements.phpt Fix number of elements after packed hash filling (#11022) 2023-04-06 21:54:59 +02:00
internal-call-internal-static-return.phpt Close PHP tags in tests 2023-10-18 17:34:10 +02:00
internal_dnf_arguments.phpt Adds support for DNF types in internal functions and properties (#11969) 2023-08-19 00:11:06 +01:00
internal_magic_call.phpt Fix leak of call->extra_named_params on internal __call 2023-12-01 16:49:16 +01:00
observer.inc
observer_backtrace_01.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_basic_01.phpt Merge branch 'PHP-8.2' of github.com:php/php-src into PHP-8.3 2024-04-02 18:11:55 +02:00
observer_basic_02.phpt Merge branch 'PHP-8.2' of github.com:php/php-src into PHP-8.3 2024-04-02 18:11:55 +02:00
observer_basic_03.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_basic_04.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_basic_05.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_basic_06.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_bug81430_1.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_bug81430_2.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_bug81435.phpt Optimize observers (#13649) 2024-06-15 14:42:27 +02:00
observer_call_user_func_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_call_user_func_02.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_call_user_func_03.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_call_user_func_04.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_closure_01.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_closure_02.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_closure_03.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_declarations_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_declarations_file_cache.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_error_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_error_02.phpt ext/core: Deprecate passing E_USER_ERROR to trigger_error() (#15308) 2024-08-09 15:51:07 +01:00
observer_error_03.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_error_04.phpt Update test for changed error message format in libxml 2.13 2024-09-12 23:11:14 +02:00
observer_error_05.phpt ext/core: Deprecate passing E_USER_ERROR to trigger_error() (#15308) 2024-08-09 15:51:07 +01:00
observer_eval_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_exception_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_fiber_01.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_02.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_03.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_04.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_05.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_06.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_functions_01.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_functions_02.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_fiber_functions_03.phpt Merge branch 'PHP-8.3' into PHP-8.4 2024-10-06 18:00:49 +02:00
observer_frameless.phpt Optimize observers (#13649) 2024-06-15 14:42:27 +02:00
observer_generator_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_generator_02.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_generator_03.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_generator_04.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_generator_05.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_magic_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_opline_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_preload.inc Fix opcache preload with observers enabled 2022-11-09 16:36:28 +01:00
observer_preload.phpt Allow optimizer to depend on preloaded symbols (#15021) 2024-08-02 17:35:27 +02:00
observer_retval_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_02.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_03.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_04.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_05.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_06.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_07.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_by_ref_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_by_ref_02.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_retval_by_ref_03.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_shutdown_01.phpt Include the source location in Closure names (#13550) 2024-04-12 18:21:13 +02:00
observer_shutdown_02.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_sqlite_create_function.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_types_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
observer_zend_call_function_01.phpt Run one testsuite with observers enabled in CI (#13869) 2024-04-02 18:11:02 +02:00
opline_dangling.phpt Add runtime-enabled heap debugging capabilities (#18172) 2025-03-31 17:24:42 +02:00
opline_dangling_02.phpt Add runtime-enabled heap debugging capabilities (#18172) 2025-03-31 17:24:42 +02:00
optimizer_register_pass.phpt Skip some tests under --preload 2021-07-30 17:26:39 +02:00
strings_marked_as_utf8.phpt Propagate UTF-8 flag during Rope operations (#10915) 2023-03-26 14:18:46 +01:00
strings_not_marked_as_utf8.phpt Propagate UTF-8 flag during Rope operations (#10915) 2023-03-26 14:18:46 +01:00
variadic_arguments.phpt Fixed strict zpp arginfo test 2023-03-09 11:40:47 +00:00
zend_forbid_dynamic_call.phpt Use get_active_function_or_method_name() for zend_forbid_dynamic_call() (#8762) 2022-06-16 12:02:53 +01:00
zend_ini_str_validator_basic.phpt Add zend_string INI validators 2022-09-06 10:41:47 +01:00
zend_ini_str_validator_return_from_func.phpt Add zend_string INI validators 2022-09-06 10:41:47 +01:00
zend_internal_class_prop_intersection.phpt Add support for stubs to declare intersection type class properties (#8751) 2022-07-22 13:04:49 +01:00
zend_legacy_iterable.phpt Make ReflectionGenerator::getFunction() legal after generator termination (#14167) 2024-05-21 08:54:51 +02:00
zend_mm_custom_handlers_alloc_01.phpt Add gc and shutdown callbacks to ZendMM custom handlers (#13432) 2024-06-19 19:43:57 +02:00
zend_mm_custom_handlers_free_01.phpt Add gc and shutdown callbacks to ZendMM custom handlers (#13432) 2024-06-19 19:43:57 +02:00
zend_mm_custom_handlers_gc_01.phpt Add gc and shutdown callbacks to ZendMM custom handlers (#13432) 2024-06-19 19:43:57 +02:00
zend_object_init_with_constructor.phpt Zend: Add object_init_with_constructor() API (#14440) 2024-06-06 21:21:16 +01:00
zend_object_init_with_constructor_classes_without_constructor.phpt Zend: Add object_init_with_constructor() API (#14440) 2024-06-06 21:21:16 +01:00
zend_test_compile_string.phpt Fix GH-17831: zend_test_compile_string crash on nul bytes check. (#17832) 2025-02-16 11:14:19 +00:00
zend_weakmap.phpt Convert iterable into an internal alias for Traversable|array (#7309) 2022-06-07 13:35:34 +01:00