Skip to content

Memory leaks when opcache preloading non-exist file #14049

Description

@YuanchengJiang

Description

The following command:

USE_ZEND_ALLOC=1 /php-src/sapi/cli/php  -n -c '/php-src/tmp-php.ini' -d "extension_dir=/php-src/modules/" -d "zend_extension=/php-src/modules/opcache.so" -d "opcache.enable_cli=1" -d "opcache.preload=non_exist_file"

Resulted in this output:

Warning: PHP Startup: Failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Failed opening required 'non_exist_file' (include_path='.:') in Unknown on line 0

=================================================================
==2657753==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 3040 byte(s) in 95 object(s) allocated from:
    #0 0x557630088c0e in malloc (/php-src/sapi/cli/php+0x1c88c0e) (BuildId: 41fa132f3fca034615336154396bda4da9dab77f)
    #1 0x5576321d7ab8 in zend_register_functions /php-src/Zend/zend_API.c:3030:19
    #2 0x5576321d039b in zend_register_module_ex /php-src/Zend/zend_API.c:2548:27
    #3 0x5576321da059 in zend_register_internal_module /php-src/Zend/zend_API.c:2564:9
    #4 0x557631cf3578 in php_register_extensions /php-src/main/main.c:2004:8
    #5 0x5576330c1184 in php_register_internal_extensions /php-src/main/internal_functions_cli.c:86:9
    #6 0x557631cf4186 in php_module_startup /php-src/main/main.c:2204:6
    #7 0x5576330c8ee8 in php_cli_startup /php-src/sapi/cli/php_cli.c:410:9
    #8 0x5576330c2876 in main /php-src/sapi/cli/php_cli.c:1307:6
    #9 0x7f9ef5718d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
...
Indirect leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x557630088c0e in malloc (/php-src/sapi/cli/php+0x1c88c0e) (BuildId: 41fa132f3fca034615336154396bda4da9dab77f)
    #1 0x5576321d862e in zend_register_functions /php-src/Zend/zend_API.c:3056:30
    #2 0x5576321e862f in do_register_internal_class /php-src/Zend/zend_API.c:3382:3
    #3 0x5576321e7836 in zend_register_internal_class /php-src/Zend/zend_API.c:3446:9
    #4 0x5576321e77e8 in zend_register_internal_class_ex /php-src/Zend/zend_API.c:3409:19
    #5 0x55763156f891 in register_class_FilesystemIterator /php-src/ext/spl/spl_directory_arginfo.h:513:16
    #6 0x55763156acfb in zm_startup_spl_directory /php-src/ext/spl/spl_directory.c:2770:30
    #7 0x55763146d74e in zm_startup_spl /php-src/ext/spl/php_spl.c:728:2
    #8 0x5576321ca596 in zend_startup_module_ex /php-src/Zend/zend_API.c:2342:7
    #9 0x5576321cf431 in zend_startup_module_zval /php-src/Zend/zend_API.c:2357:10
    #10 0x557632277e94 in zend_hash_apply /php-src/Zend/zend_hash.c:2080:13
    #11 0x5576321ce68f in zend_startup_modules /php-src/Zend/zend_API.c:2480:2
    #12 0x557631cf4231 in php_module_startup /php-src/main/main.c:2222:2
    #13 0x5576330c8ee8 in php_cli_startup /php-src/sapi/cli/php_cli.c:410:9
    #14 0x5576330c2876 in main /php-src/sapi/cli/php_cli.c:1307:6
    #15 0x7f9ef5718d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

SUMMARY: AddressSanitizer: 26088 byte(s) leaked in 815 allocation(s).

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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