lihancong / tonyenc

高性能、跨平台的 PHP7 代码加密扩展 (A high performance and cross-platform encrypt extension for PHP source code)
725 stars 202 forks source link

php7.3.7版本遇到内存泄漏问题 #17

Closed toxmc closed 5 years ago

toxmc commented 5 years ago

PHP版本以及环境

[root@DESKTOP-C05T56D solution ]$ php737 -v      
PHP 7.3.7 (cli) (built: Sep 29 2019 09:34:46) ( NTS DEBUG )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies

[root@DESKTOP-C05T56D solution ]$ uname -a
Linux DESKTOP-C05T56D 4.4.0-18362-Microsoft #1-Microsoft Mon Mar 18 12:02:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

test.php 文件

<?php
echo 33;

运行后提示一处内存错误

[root@DESKTOP-C05T56D solution ]$ php737 test.php
33[Thu Oct 10 11:20:02 2019]  Script:  '/mnt/c/Users/You/c/php-7.3.7/ext/solution/test.php'
/home/xmc/oneinstack/src/php-7.3.7/Zend/zend_string.h(133) :  Freeing 0x00007fd5f6470150 (80 bytes), script=/mnt/c/Users/You/c/php
-7.3.7/ext/solution/test.php
=== Total 1 memory leaks detected ===

valgrind执行获取的信息

[root@DESKTOP-C05T56D solution ]$ valgrind --leak-check=full  --show-leak-kinds=all php737 test.php                
==7255== Memcheck, a memory error detector
==7255== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==7255== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==7255== Command: php737 test.php
==7255== 
==7255== error calling PR_SET_PTRACER, vgdb might block
==7255== Conditional jump or move depends on uninitialised value(s)
==7255==    at 0x51D037: zend_string_equal_val (zend_string.c:417)
==7255==    by 0x4F191B: zend_string_equal_content (zend_string.h:310)
==7255==    by 0x4F3B18: zend_hash_find_bucket (zend_hash.c:587)
==7255==    by 0x4F8E30: zend_hash_find (zend_hash.c:2092)
==7255==    by 0x4C4F86: zend_get_constant_impl (zend_constants.c:279)
==7255==    by 0x4C511D: zend_get_constant (zend_constants.c:301)
==7255==    by 0x49AA0A: zend_ini_get_constant (zend_ini_parser.c:223)
==7255==    by 0x49C0F5: ini_parse (zend_ini_parser.c:1927)
==7255==    by 0x49AE5D: zend_parse_ini_file (zend_ini_parser.c:309)
==7255==    by 0x456DE3: php_init_config (php_ini.c:630)
==7255==    by 0x44C7E7: php_module_startup (main.c:2270)
==7255==    by 0x5BA9D4: php_cli_startup (php_cli.c:420)
==7255== 
==7255== Conditional jump or move depends on uninitialised value(s)
==7255==    at 0x51D037: zend_string_equal_val (zend_string.c:417)
==7255==    by 0x4F191B: zend_string_equal_content (zend_string.h:310)
==7255==    by 0x4F3B18: zend_hash_find_bucket (zend_hash.c:587)
==7255==    by 0x4F3E8A: _zend_hash_add_or_update_i (zend_hash.c:670)
==7255==    by 0x4F4621: zend_hash_update (zend_hash.c:817)
==7255==    by 0x4560CD: php_ini_parser_cb (php_ini.c:239)
==7255==    by 0x49BA2F: ini_parse (zend_ini_parser.c:1676)
==7255==    by 0x49AE5D: zend_parse_ini_file (zend_ini_parser.c:309)
==7255==    by 0x456DE3: php_init_config (php_ini.c:630)
==7255==    by 0x44C7E7: php_module_startup (main.c:2270)
==7255==    by 0x5BA9D4: php_cli_startup (php_cli.c:420)
==7255==    by 0x5BCB54: main (php_cli.c:1356)
==7255== 
==7255== Conditional jump or move depends on uninitialised value(s)
==7255==    at 0x51D037: zend_string_equal_val (zend_string.c:417)
==7255==    by 0x51C2ED: zend_string_equal_content (zend_string.h:310)
==7255==    by 0x51CA69: zend_interned_string_ht_lookup (zend_string.c:156)
==7255==    by 0x51CBA4: zend_new_interned_string_permanent (zend_string.c:196)
==7255==    by 0x5077D3: zend_register_ini_entries (zend_ini.c:261)
==7255==    by 0x44C80A: php_module_startup (main.c:2275)
==7255==    by 0x5BA9D4: php_cli_startup (php_cli.c:420)
==7255==    by 0x5BCB54: main (php_cli.c:1356)
==7255== 
==7255== Conditional jump or move depends on uninitialised value(s)
==7255==    at 0x51D037: zend_string_equal_val (zend_string.c:417)
==7255==    by 0x4F191B: zend_string_equal_content (zend_string.h:310)
==7255==    by 0x4F5F61: zend_hash_del (zend_hash.c:1235)
==7255==    by 0x4EEB1C: zend_declare_property_ex (zend_API.c:3748)
==7255==    by 0x4EEE2F: zend_declare_property (zend_API.c:3793)
==7255==    by 0x4EF0B0: zend_declare_property_string (zend_API.c:3840)
==7255==    by 0x30B2EE: zm_startup_reflection (php_reflection.c:6650)
==7255==    by 0x4E8067: zend_startup_module_ex (zend_API.c:1878)
==7255==    by 0x4E80C2: zend_startup_module_zval (zend_API.c:1893)
==7255==    by 0x4F7823: zend_hash_apply (zend_hash.c:1689)
==7255==    by 0x4E8706: zend_startup_modules (zend_API.c:2004)
==7255==    by 0x44C8F5: php_module_startup (main.c:2333)
==7255== 
33[Thu Oct 10 11:22:15 2019]  Script:  '/mnt/c/Users/You/c/php-7.3.7/ext/solution/test.php'
/home/xmc/oneinstack/src/php-7.3.7/Zend/zend_string.h(133) :  Freeing 0x000000000647d150 (80 bytes), script=/mnt/c/Users/You/c/php-7.3.7/ext/solution/test.php
=== Total 1 memory leaks detected ===
==7255== 
==7255== HEAP SUMMARY:
==7255==     in use at exit: 32 bytes in 1 blocks
==7255==   total heap usage: 7,050 allocs, 7,049 frees, 1,158,714 bytes allocated
==7255== 
==7255== 32 bytes in 1 blocks are still reachable in loss record 1 of 1
==7255==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7255==    by 0x55FE7E4: _dlerror_run (dlerror.c:140)
==7255==    by 0x55FE050: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==7255==    by 0x38EBC5: php_load_shlib (dl.c:84)
==7255==    by 0x38EDC6: php_load_extension (dl.c:149)
==7255==    by 0x4564AB: php_load_php_extension_cb (php_ini.c:344)
==7255==    by 0x4CBE7D: zend_llist_apply (zend_llist.c:182)
==7255==    by 0x4575C0: php_ini_register_extensions (php_ini.c:777)
==7255==    by 0x44C8F0: php_module_startup (main.c:2332)
==7255==    by 0x5BA9D4: php_cli_startup (php_cli.c:420)
==7255==    by 0x5BCB54: main (php_cli.c:1356)
==7255== 
==7255== LEAK SUMMARY:
==7255==    definitely lost: 0 bytes in 0 blocks
==7255==    indirectly lost: 0 bytes in 0 blocks
==7255==      possibly lost: 0 bytes in 0 blocks
==7255==    still reachable: 32 bytes in 1 blocks
==7255==         suppressed: 0 bytes in 0 blocks
==7255== 
==7255== For counts of detected and suppressed errors, rerun with: -v
==7255== Use --track-origins=yes to see where uninitialised values come from
==7255== ERROR SUMMARY: 231 errors from 4 contexts (suppressed: 0 from 0)
[root@DESKTOP-C05T56D solution ]$ 
toxmc commented 5 years ago

fixed at pull#18