View Issue Details

IDProjectCategoryView StatusLast Update
0002322XdebugStep Debuggingpublic2025-04-04 13:36
Reportermartti Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.4.1 
Target Version3.4devFixed in Version3.4dev 
Summary0002322: Xdebug tries to open debugging connection in destructors during shutdown
Description

Xdebug tries to open debugging connection continuously to client while php is shutting down

This seems to be happening if there is lots of objects with __destruct -method defined.

Steps To Reproduce

Run destruct.php while client is not listening for connections

TagsNo tags attached.
Attached Files
backtrace.txt (3,180 bytes)   
(gdb) zbacktrace
[0xfffff4016020] Testing->__destruct() /app/destruct.php:7 
(gdb) backtrace
#0  0x0000fffff737d9f4 in poll () from /lib/aarch64-linux-gnu/libc.so.6
#1  0x0000fffff73ad2e4 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
#2  0x0000fffff73adda4 in __res_context_send () from /lib/aarch64-linux-gnu/libc.so.6
#3  0x0000fffff73ab6d0 in __res_context_query () from /lib/aarch64-linux-gnu/libc.so.6
#4  0x0000fffff73ac1e8 in __res_context_search () from /lib/aarch64-linux-gnu/libc.so.6
#5  0x0000fffff73a5be0 in _nss_dns_gethostbyname4_r () from /lib/aarch64-linux-gnu/libc.so.6
#6  0x0000fffff7373738 in getaddrinfo () from /lib/aarch64-linux-gnu/libc.so.6
#7  0x0000fffff3c5d990 in xdebug_create_socket (hostname=0xaaaaabf59ce8 "host.docker.internal", dport=9003, timeout=50)
    at /tmp/pear/temp/xdebug/src/debugger/com.c:237
#8  0x0000fffff3c5e120 in xdebug_init_normal_debugger (connection_attempts=0xaaaaac1db7a0) at /tmp/pear/temp/xdebug/src/debugger/com.c:475
#9  0x0000fffff3c5e6e4 in xdebug_init_debugger () at /tmp/pear/temp/xdebug/src/debugger/com.c:595
#10 0x0000fffff3c5f064 in xdebug_debug_init_if_requested_at_startup () at /tmp/pear/temp/xdebug/src/debugger/com.c:820
#11 0x0000fffff3c39a20 in xdebug_execute_user_code_begin (execute_data=0xfffff4016020) at /tmp/pear/temp/xdebug/src/base/base.c:739
#12 0x0000fffff3c3a570 in xdebug_execute_begin (execute_data=0xfffff4016020) at /tmp/pear/temp/xdebug/src/base/base.c:1039
#13 0x0000aaaaab32bc34 in _zend_observe_fcall_begin (execute_data=0xfffff4016020) at /usr/src/php/Zend/zend_observer.c:244
#14 0x0000aaaaab32bce8 in zend_observer_fcall_begin (execute_data=0xfffff4016020) at /usr/src/php/Zend/zend_observer.c:257
#15 0x0000aaaaab1e05d8 in zend_call_function (fci=0xffffffffd2e8, fci_cache=0xffffffffd2c0) at /usr/src/php/Zend/zend_execute_API.c:960
#16 0x0000aaaaab1e0b10 in zend_call_known_function (fn=0xfffff40a1218, object=0xfffff40bd1e0, called_scope=0xfffff40a1018, retval_ptr=0x0, 
    param_count=0, params=0x0, named_params=0x0) at /usr/src/php/Zend/zend_execute_API.c:1055
#17 0x0000aaaaab313dbc in zend_call_known_instance_method (fn=0xfffff40a1218, object=0xfffff40bd1e0, retval_ptr=0x0, param_count=0, 
    params=0x0) at /usr/src/php/Zend/zend_API.h:853
#18 0x0000aaaaab313df4 in zend_call_known_instance_method_with_0_params (fn=0xfffff40a1218, object=0xfffff40bd1e0, retval_ptr=0x0)
    at /usr/src/php/Zend/zend_API.h:859
#19 0x0000aaaaab3144a4 in zend_objects_destroy_object (object=0xfffff40bd1e0) at /usr/src/php/Zend/zend_objects.c:173
#20 0x0000aaaaab31c560 in zend_objects_store_call_destructors (objects=0xaaaaabf23d20 <executor_globals+840>)
    at /usr/src/php/Zend/zend_objects_API.c:59
#21 0x0000aaaaab1ddbe8 in shutdown_destructors () at /usr/src/php/Zend/zend_execute_API.c:262
#22 0x0000aaaaab1fb8ec in zend_call_destructors () at /usr/src/php/Zend/zend.c:1281
#23 0x0000aaaaab136498 in php_request_shutdown (dummy=0x0) at /usr/src/php/main/main.c:1872
#24 0x0000aaaaab3a90dc in do_cli (argc=2, argv=0xaaaaabf40ae0) at /usr/src/php/sapi/cli/php_cli.c:1137
#25 0x0000aaaaab3a95ec in main (argc=2, argv=0xaaaaabf40ae0) at /usr/src/php/sapi/cli/php_cli.c:1341
(gdb) 

backtrace.txt (3,180 bytes)   
destruct.php (139 bytes)   
<?php
class Testing
{
	function __destruct() {
		echo "Destruct";
	}
}

$t = array();
for ($i=0; $i<1000; $i++) {
	$t[] = new Testing();
}
destruct.php (139 bytes)   
xdebug.log (1,920,292 bytes)
Operating System
PHP Version8.3.10-8.3.19

Activities

derick

2025-04-04 10:59

administrator   ~0007226

During analysis, I found that this only happens when the destructors are called when the object goes out of the global scope only.

For example, this version does not show the same behaviour:

<?php
class Testing
{
    function __destruct() {
        echo "Destruct";
    }
}

function a() {
    $t = array();
    for ($i=0; $i<5; $i++) {
        $t[] = new Testing();
    }
}

a();

derick

2025-04-04 11:12

administrator   ~0007227

https://github.com/xdebug/xdebug/pull/1004

Issue History

Date Modified Username Field Change
2025-02-24 11:38 martti New Issue
2025-02-24 11:38 martti File Added: backtrace.txt
2025-02-24 11:38 martti File Added: destruct.php
2025-02-24 11:38 martti File Added: xdebug.log
2025-04-04 10:59 derick Note Added: 0007226
2025-04-04 11:12 derick Status new => assigned
2025-04-04 11:12 derick Target Version => 3.4dev
2025-04-04 11:12 derick Summary Xdebug tries to open debugging connection continuously to client while php is shutting down => Xdebug tries to open debugging connection in destructors during shutdown
2025-04-04 11:12 derick Note Added: 0007227
2025-04-04 13:36 derick Assigned To => derick
2025-04-04 13:36 derick Status assigned => closed
2025-04-04 13:36 derick Resolution open => fixed
2025-04-04 13:36 derick Fixed in Version => 3.4dev