php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79900 Memory leaks reported in zend_objects_new with zend.enable_gc=0
Submitted: 2020-07-26 22:56 UTC Modified: 2020-07-28 14:28 UTC
From: tandre@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 8.0Git-2020-07-26 (Git) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tandre@php.net
New email:
PHP Version: OS:

 

 [2020-07-26 22:56 UTC] tandre@php.net
Description:
------------
When gc is disabled, PHP builds containing --enable-debug report a variety of memory leaks during PHP shutdown.

I'm not sure if this is reflective of an actual memory leak or whether this is a deliberate change in php 8.0. It's distracting when trying to debug issues, though.

Many large applications disable gc because it has historically been slow in older php versions, e.g. I noticed this when running composer and http://github.com/phan/phan/ (which creates objects with reference cycles, e.g. Type to UnionType to the type itself.

For example, during --enable-debug, calling gc_collect_cycles() during shutdown may cut down on noise about memory leaks, but that may itself be an inconsistency

```
ยป php run-tests.php -d zend.enable_gc=0 Zend/tests/bug61165.phpt --show-diff

=====================================================================
PHP         : /path/to/php-8.0.0-debug-plain-install/bin/php
PHP_SAPI    : cli
PHP_VERSION : 8.0.0-dev
ZEND_VERSION: 4.0.0-dev
PHP_OS      : Linux - Linux student3 4.15.0-72-generic #81~16.04.1-Ubuntu SMP Tue Nov 26 16:34:21 UTC 2019 x86_64
INI actual  : /path/to/php-src
More .INIs  :
---------------------------------------------------------------------
PHP         : /path/to/php-src/sapi/phpdbg/phpdbg
PHP_SAPI    : phpdbg
PHP_VERSION : 8.0.0-dev
ZEND_VERSION: 4.0.0-dev
PHP_OS      : Linux - Linux student3 4.15.0-72-generic #81~16.04.1-Ubuntu SMP Tue Nov 26 16:34:21 UTC 2019 x86_64
INI actual  : /path/to/php-src
More .INIs  :
---------------------------------------------------------------------
CWD         : /path/to/php-src
Extra dirs  :
VALGRIND    : Not used
=====================================================================
Running selected tests.
TEST 1/1 [Zend/tests/bug61165.phpt]
========DIFF========
005+ [Sun Jul 26 18:45:57 2020]  Script:  '/path/to/php-src/Zend/tests/bug61165.php'
006+ /path/to/programming/php-src/Zend/zend_objects.c(178) :  Freeing 0x00007f3c2ea039c0 (56 bytes), script=/path/to/php-src/Zend/tests/bug61165.php
007+ Last leak repeated 3 times
008+ === Total 4 memory leaks detected ===
========DONE========
FAIL Bug #61165 (Segfault - strip_tags()) [Zend/tests/bug61165.phpt]
=====================================================================
Number of tests :    1                 1
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    1 (100.0%) (100.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    0 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Bug #61165 (Segfault - strip_tags()) [Zend/tests/bug61165.phpt]
=====================================================================
```

Expected result:
----------------
No memory leaks are reported, or messages should get added to clarify that php deliberately will not attempt to garbage collect cyclic object cycles if gc is disabled during shutdown.

I don't see any leaks reported in a debug 7.3 build

Actual result:
--------------
Memory leaks are reported with --enable-debug builds during shutdown

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-28 14:28 UTC] nikic@php.net
We should probably force-run GC on shutdown (in debug builds).

I don't think anything about the behavior here has actually changed, those leaks were probably just suppressed by use of "exit" previously.
 [2020-07-29 13:28 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c206c742d6225c7f4c7ffbf95e33034d8de59047
Log: Fix bug #79900
 [2020-07-29 13:28 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 11:01:22 2020 UTC