php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77785 memory leak… in "do_register_internal_class"
Submitted: 2019-03-23 11:13 UTC Modified: 2021-08-22 04:22 UTC
From: aotto1968 at t-online dot de Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 7.3.3 OS: linux latest
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: aotto1968 at t-online dot de
New email:
PHP Version: OS:

 

 [2019-03-23 11:13 UTC] aotto1968 at t-online dot de
Description:
------------
Problem… overwrite "lowercase_name" without free ressource.


==44094== 32 bytes in 1 blocks are possibly lost in loss record 1,002 of 2,699
==44094==    at 0x4C2A080: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==44094==    by 0x6A7681: __zend_malloc (zend_alloc.c:2903)
==44094==    by 0x6D1834: zend_string_alloc (zend_string.h:133)
==44094==    by 0x6DCEE3: zend_string_tolower_ex (zend_operators.c:2677)
==44094==    by 0x6EEAF7: do_register_internal_class (zend_API.c:2730)
==44094==    by 0x6EECBF: zend_register_internal_class (zend_API.c:2775)
==44094==    by 0x6EEB7E: zend_register_internal_class_ex (zend_API.c:2747)
==44094==    by 0x683E9B2: phpmsgque_MqDumpC_Init (MqDumpC_php.c:422)
==44094==    by 0x6815718: zm_startup_phpmsgque (phpmsgque.c:104)
==44094==    by 0x6EBC6A: zend_startup_module_ex (zend_API.c:1878)
==44094==    by 0x6EBCE8: zend_startup_module_zval (zend_API.c:1893)
==44094==    by 0x6FB15A: zend_hash_apply (zend_hash.c:1688)
==44094==    by 0x6EC32C: zend_startup_modules (zend_API.c:2004)
==44094==    by 0x633DE1: php_module_startup (main.c:2333)
==44094==    by 0x7C1017: php_cli_startup (php_cli.c:420)
==44094==    by 0x7C301C: main (php_cli.c:1356)


static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, uint32_t ce_flags) /* {{{ */
{   
    zend_class_entry *class_entry = malloc(sizeof(zend_class_entry));
    zend_string *lowercase_name;
    *class_entry = *orig_class_entry;

    class_entry->type = ZEND_INTERNAL_CLASS;
    zend_initialize_class_data(class_entry, 0);
    class_entry->ce_flags = ce_flags | ZEND_ACC_CONSTANTS_UPDATED;
    class_entry->info.internal.module = EG(current_module);

    if (class_entry->info.internal.builtin_functions) {
        zend_register_functions(class_entry, class_entry->info.internal.builtin_functions, &class_entry->function_table, MODULE_PERSISTENT);
    }

>>>>>    lowercase_name = zend_string_tolower_ex(orig_class_entry->name, 1);
>>>>>    lowercase_name = zend_new_interned_string(lowercase_name);
    zend_hash_update_ptr(CG(class_table), lowercase_name, class_entry);
    zend_string_release_ex(lowercase_name, 1);
    return class_entry;
}




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-12 11:11 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2021-08-12 11:11 UTC] nikic@php.net
I can't reproduce this (that is, I don't see any startup leaks with a normal PHP build -- I haven't tested the phpmsgque extension in particular). The code also looks correct to me: zend_new_interned_string releases the string passed to it.
 [2021-08-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Sep 23 19:03:37 2021 UTC