From: hao dot sun at arm dot com
Operating system: Ubuntu 20.04
PHP version: master-Git-2021-07-14 (Git)
Package: JIT
Bug Type: Bug
Bug description:Memory leak in PHPUnit with functional JIT
Description:
------------
I suppose tracing JIT is tested by the "community_job.yml" in Azure
pipeline in upstream. I further tested with functional JIT.
This error is found when running the PHPUnit with functional JIT, i.e.
opcache.jit=1205, in NTS+DEBUG+HYBRID+ASAN. It occurred in both
JIT/arm64 and JIT/x86. Here is the ASAN output. From the log, it seems
that the result of PHP_FUNCTION "tempnam" is not freed in some case.
=================================================================
==11079==ERROR: LeakSanitizer: detected memory leaksDirect leak of 48
byte(s) in 1 object(s) allocated from:
#0 0x7f1647defbc8 in malloc
(/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
#1 0x5623294a7af7 in __zend_malloc
/tmp/php-src/Zend/zend_alloc.c:3043
#2 0x5623294a6045 in tracked_malloc
/tmp/php-src/Zend/zend_alloc.c:2746
#3 0x5623294a4bfa in _malloc_custom
/tmp/php-src/Zend/zend_alloc.c:2419
#4 0x5623294a4fc6 in _emalloc /tmp/php-src/Zend/zend_alloc.c:2538
#5 0x5623293d306d in zend_string_alloc
/tmp/php-src/Zend/zend_string.h:141
#6 0x5623293d3165 in zend_string_init
/tmp/php-src/Zend/zend_string.h:163
#7 0x5623293d3684 in php_do_open_temporary_file
/tmp/php-src/main/php_open_temporary_file.c:193
#8 0x5623293d4000 in php_open_temporary_fd_ex
/tmp/php-src/main/php_open_temporary_file.c:316
#9 0x562328fbc434 in zif_tempnam
/tmp/php-src/ext/standard/file.c:843
#10 0x4a04acac (<unknown module>)
#11 0x56232975f698 in zend_execute
/tmp/php-src/Zend/zend_vm_execute.h:59034
#12 0x562329552116 in zend_execute_scripts
/tmp/php-src/Zend/zend.c:1791
#13 0x5623293990d8 in php_execute_script
/tmp/php-src/main/main.c:2523
#14 0x562329939602 in do_cli /tmp/php-src/sapi/cli/php_cli.c:965
#15 0x56232993bd67 in main /tmp/php-src/sapi/cli/php_cli.c:1366
#16 0x7f1645d900b2 in __libc_start_main
(/usr/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
SUMMARY: AddressSanitizer: 48 byte(s) leaked in 1 allocation(s).
Note-1: this bug didn't occur in php-8.1.0alpha3.
Note-2: Yesterday, I thought this bug was fixed after the commit
989205e95cde4c43b562148a5 with the following message.
--------
[Tue Jul 13 04:06:40 2021] Script: '/tmp/php-oss/phpunit/phpunit'
/tmp/php-src/Zend/zend_string.h(141) : Freeing 0x00007f8a82b729b0 (48
bytes), script=/tmp/php-oss/phpunit/phpunit
=== Total 1 memory leaks detected ===
--------
commit 989205e95cde4c43b562148a5f35fe32bb7af3da
Author: Nikita Popov <nikita.ppv@gmail.com>
Date: Mon Jul 12 16:56:00 2021 +0200 Remove incorrect uses of
zend_atoi() zend_atoi() parses integers with size suffixes (like
"128M").
These just want to use a plain number, so use ZEND_ATOL instead.
Zend/zend.c | 2 +-
Zend/zend_alloc.c | 6 +++---
ext/session/session.c | 3 +--
sapi/cli/php_cli.c | 2 +-
4 files changed, 6 insertions(+), 7 deletions(-)
But this bug showed up again with the latest code.
--------
commit 95da6e807a948039d3a42defbd849c4fed6cbe35
Merge: d550c848 88d6fbe0
Author: Derick Rethans <github@derickrethans.nl>
Date: Tue Jul 13 17:21:54 2021 +0100
Merge branch 'PHP-8.0'
Test script:
---------------
Following the "community_job.xml", download PHPUnit test case and run
"php ./phpunit".
The version of PHPUnit I used is
--------
commit 40d747f72010bcb9d68b9781756d3d96481d4292
Author: Sebastian Bergmann <sb@sebastian-bergmann.de>
Date: Tue Jul 13 08:42:57 2021 +0200
Sync with
https://github.com/sebastianbergmann/type/commit/63aee82dc152c48b7633f57f037914bfd9531878--
Edit bug report at https://bugs.php.net/bug.php?id=81255&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81255&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81255&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81255&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81255&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81255&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81255&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81255&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81255&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81255&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81255&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81255&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81255&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81255&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81255&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81255&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81255&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81255&r=mysqlcfg