Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak #18139

Open
chongwick opened this issue Mar 24, 2025 · 1 comment
Open

Memory Leak #18139

chongwick opened this issue Mar 24, 2025 · 1 comment

Comments

@chongwick
Copy link

Description

The following code:

<?php
define("MAX_64Bit", 9223372036854775807);
define("MAX_32Bit", 2147483647);
define("MIN_64Bit", -9223372036854775807 - 1);
define("MIN_32Bit", -2147483647 - 1);

$longVals = array(
    MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
    MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
    MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
);

foreach ($longVals as $longVal) {
   var_dump(readline_info('readline_name', 1));
}

?>

Resulted in this output:

==1296481==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 28 byte(s) in 14 object(s) allocated from:
    #0 0x151407c2b9a7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x561486e92e7c in zif_readline_info /home/w023dtc/nightly_php/php-src/ext/readline/readline.c:277
    #2 0x561487bb47cc in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:1363
    #3 0x561487bb47cc in execute_ex /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:58820
    #4 0x561487bf4b0f in zend_execute /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:64247
    #5 0x561487db7bef in zend_execute_script /home/w023dtc/nightly_php/php-src/Zend/zend.c:1941
    #6 0x5614875601e3 in php_execute_script_ex /home/w023dtc/nightly_php/php-src/main/main.c:2584
    #7 0x561487dbd285 in do_cli /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:938
    #8 0x561486148c32 in main /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:1313
    #9 0x151403e82d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)

SUMMARY: AddressSanitizer: 28 byte(s) leaked in 14 allocation(s).

PHP Version

nightly

Operating System

ubuntu 22.04

@devnexen
Copy link
Member

Hmmm, ideally before assigning the new value to this global, we might free it ... but the line is commented, must trigger an issue down the line I guess. I ll have a look.

@devnexen devnexen self-assigned this Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants