Skip to content

TMPVAR object with hook creating a self-reference leaks #18907

Closed
@nielsdos

Description

@nielsdos

Description

The following code:

<?php

class Foo {
    public $prop { get {
        $this->prop = $this;
        return $this;
    }}
}

(new Foo)->prop;

Resulted in this output:

=================================================================
==706473==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x7f3c37120e15 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:67
    #1 0x556f537019ed in __zend_malloc /run/media/niels/MoreData/php-src/Zend/zend_alloc.c:3518
    #2 0x556f536fd981 in _emalloc /run/media/niels/MoreData/php-src/Zend/zend_alloc.c:2762
    #3 0x556f53aad029 in zend_objects_new /run/media/niels/MoreData/php-src/Zend/zend_objects.c:210
    #4 0x556f537149d4 in _object_and_properties_init /run/media/niels/MoreData/php-src/Zend/zend_API.c:1828
    #5 0x556f53714b86 in object_init_ex /run/media/niels/MoreData/php-src/Zend/zend_API.c:1851
    #6 0x556f5387e5bb in ZEND_NEW_SPEC_CONST_UNUSED_HANDLER /run/media/niels/MoreData/php-src/Zend/zend_vm_execute.h:11042
    #7 0x556f539a00f4 in execute_ex /run/media/niels/MoreData/php-src/Zend/zend_vm_execute.h:60061
    #8 0x556f539afa32 in zend_execute /run/media/niels/MoreData/php-src/Zend/zend_vm_execute.h:64385
    #9 0x556f53b158b9 in zend_execute_script /run/media/niels/MoreData/php-src/Zend/zend.c:1943
    #10 0x556f5354ffb0 in php_execute_script_ex /run/media/niels/MoreData/php-src/main/main.c:2594
    #11 0x556f535503b8 in php_execute_script /run/media/niels/MoreData/php-src/main/main.c:2634
    #12 0x556f53b1b5c8 in do_cli /run/media/niels/MoreData/php-src/sapi/cli/php_cli.c:952
    #13 0x556f53b1dc1a in main /run/media/niels/MoreData/php-src/sapi/cli/php_cli.c:1363
    #14 0x7f3c36b886b4  (/usr/lib/libc.so.6+0x276b4) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
    #15 0x7f3c36b88768 in __libc_start_main (/usr/lib/libc.so.6+0x27768) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
    #16 0x556f52a03fb4 in _start (/run/media/niels/MoreData/php-src/sapi/cli/php+0x603fb4) (BuildId: 2a1a4f16068276f3efa4ba67d81c1a989371a979)

But I expected this output instead:

no leak

PHP Version

8.4+

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions