Skip to content

zend_test_compile_to_ast leaks memory when PHP is compiled with --enable-address-sanitizer #22422

Description

@mainframe98

Description

When compiling zend_test using phpize with --enable-address-sanitizer, several tests using zend_test_compile_to_ast report memory leaks (e.g. compile_to_ast/basic_ast.phpt):

'php-src/ext/zend_test/tests/compile_to_ast/basic_ast.php'
php-src/Zend/zend_arena.h(171) :  Freeing 0x00007f6290803030 (16 bytes), script=php-src/ext/zend_test/tests/compile_to_ast/basic_ast.php
Last leak repeated 77 times
=== Total 78 memory leaks detected ===

I'm writing an extension modifies the ast, and its tests dumps the ast after the extension has modified the ast, but those tests keep failing because of the reported memory leaks. As this happens also in zend_test, the cause has to lie in PHP itself. Unfortunately, I don't know enough about address santization to know whether I've stumbled across a bug, or if I'm doing something wrong.

I compiled PHP with:

./buildconf
./configure --disable-all --enable-debug --enable-mbstring --disable-mbregex --enable-address-sanitizer --enable-tokenizer
make -j6
make install

PHP Version

PHP 8.6.0-dev (cli) (built: Jun 24 2026 10:50:55) (NTS DEBUG)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0-dev, Copyright © Zend by Perforce
    with Zend OPcache v8.6.0-dev, Copyright ©, by Zend by Perforce

(Compiled from 6f0aa11d23a350e01f4d14112333281eb2b0d77a)

Operating System

Debian 13.5

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions