Skip to content

memory leak #18247

Closed
Closed
@chongwick

Description

@chongwick

Description

The following code:

<?php
for ($i = 0; $i < 1111111; $i++) {
    $fp = dba_popen('/path/to/some/file', 'r');
    fwrite($fp, sprintf("%f", $i));
}
?>

Resulted in this output:

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x148ef1e42a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x5578ec2983f5 in __zend_malloc /home/w023dtc/nightly_php/php-src/Zend/zend_alloc.c:3280
    #2 0x5578ec2983f5 in __zend_calloc /home/w023dtc/nightly_php/php-src/Zend/zend_alloc.c:3292
    #3 0x5578eaffbb23 in php_dba_open /home/w023dtc/nightly_php/php-src/ext/dba/dba.c:783
    #4 0x5578ec6c27cc in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:1363
    #5 0x5578ec6c27cc in execute_ex /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:58820
    #6 0x5578ec702b0f in zend_execute /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:64247
    #7 0x5578ec8c5bef in zend_execute_script /home/w023dtc/nightly_php/php-src/Zend/zend.c:1941
    #8 0x5578ec06e1e3 in php_execute_script_ex /home/w023dtc/nightly_php/php-src/main/main.c:2584
    #9 0x5578ec8cb285 in do_cli /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:938
    #10 0x5578eac56c32 in main /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:1313
    #11 0x148eee040d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x148ef1e42887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5578ec27b0c4 in __zend_malloc /home/w023dtc/nightly_php/php-src/Zend/zend_alloc.c:3280
    #2 0x5578eaffbc2d in zend_string_alloc /home/w023dtc/nightly_php/php-src/Zend/zend_string.h:176
    #3 0x5578eaffbc2d in zend_string_init /home/w023dtc/nightly_php/php-src/Zend/zend_string.h:198
    #4 0x5578eaffbc2d in php_dba_zend_string_dup_safe /home/w023dtc/nightly_php/php-src/ext/dba/dba.c:511
    #5 0x5578eaffbc2d in php_dba_open /home/w023dtc/nightly_php/php-src/ext/dba/dba.c:784
    #6 0x5578ec6c27cc in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:1363
    #7 0x5578ec6c27cc in execute_ex /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:58820
    #8 0x5578ec702b0f in zend_execute /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:64247
    #9 0x5578ec8c5bef in zend_execute_script /home/w023dtc/nightly_php/php-src/Zend/zend.c:1941
    #10 0x5578ec06e1e3 in php_execute_script_ex /home/w023dtc/nightly_php/php-src/main/main.c:2584
    #11 0x5578ec8cb285 in do_cli /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:938
    #12 0x5578eac56c32 in main /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:1313
    #13 0x148eee040d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)

SUMMARY: AddressSanitizer: 136 byte(s) leaked in 2 allocation(s).

But I expected this output instead:

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions