View Issue Details

IDProjectCategoryView StatusLast Update
0002305XdebugUncategorizedpublic2024-11-28 13:41
ReporterRuggMatt Assigned Toderick  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version3.4.0beta1 
Target Version3.4devFixed in Version3.4.0 
Summary0002305: Segfault when checking whether to ignore creating a debug connection during shutdown functions
Description

The beta version produces a segfault when simply running the provided script. I was trying the beta because i wanted to upgrade to PHP 8.4 and narrowed down the issue to these two functions being called together.

3.3.2 works fine. beta does not.

Steps To Reproduce

Run the following script via cli

php script.php
    <?php

    register_shutdown_function(function () {});
    parse_str("", $_POST);
Additional Information

PHP 8.3.13 (cli) (built: Nov 12 2024 02:08:29) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.13, Copyright (c) Zend Technologies
with Xdebug v3.4.0beta1, Copyright (c) 2002-2024, by Derick Rethans

TagsNo tags attached.
Attached Files
script.php (78 bytes)   
<?php

register_shutdown_function(function () {});
parse_str("", $_POST);
script.php (78 bytes)   
gbd backtrace.txt (1,348 bytes)   
Program received signal SIGSEGV, Segmentation fault.
0x000055555597b652 in zend_hash_str_find ()
(gdb) bt full
#0  0x000055555597b652 in zend_hash_str_find ()
No symbol table info available.
#1  0x00007ffff7091467 in xdebug_lib_find_in_globals () from /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so
No symbol table info available.
#2  0x00007ffff70a2273 in xdebug_should_ignore () from /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so
No symbol table info available.
#3  0x00007ffff70a2475 in xdebug_debug_init_if_requested_at_startup ()
   from /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so
No symbol table info available.
#4  0x00007ffff708bbc1 in ?? () from /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so
No symbol table info available.
#5  0x00007ffff708c208 in ?? () from /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so
No symbol table info available.
#6  0x0000555555a04533 in ?? ()
No symbol table info available.
#7  0x0000555555956c9b in zend_call_function ()
No symbol table info available.
#8  0x0000555555869778 in ?? ()
No symbol table info available.
#9  0x0000555555978962 in zend_hash_apply ()
No symbol table info available.
#10 0x000055555586f166 in php_call_shutdown_functions ()
No symbol table info available.
gbd backtrace.txt (1,348 bytes)   
valgrind.log (4,859 bytes)   
==29315== Memcheck, a memory error detector
==29315== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==29315== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==29315== Command: php html/a-testing/superpassword.php
==29315== 
==29315== Use of uninitialised value of size 8
==29315==    at 0x683652: zend_hash_str_find (in /usr/local/bin/php)
==29315==    by 0x5A92466: xdebug_lib_find_in_globals (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5AA3272: xdebug_should_ignore (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5AA3474: xdebug_debug_init_if_requested_at_startup (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5A8CBC0: ??? (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5A8D207: ??? (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x70C532: ??? (in /usr/local/bin/php)
==29315==    by 0x65EC9A: zend_call_function (in /usr/local/bin/php)
==29315==    by 0x571777: ??? (in /usr/local/bin/php)
==29315==    by 0x680961: zend_hash_apply (in /usr/local/bin/php)
==29315==    by 0x577165: php_call_shutdown_functions (in /usr/local/bin/php)
==29315==    by 0x601B14: php_request_shutdown (in /usr/local/bin/php)
==29315== 
==29315== Invalid read of size 4
==29315==    at 0x683652: zend_hash_str_find (in /usr/local/bin/php)
==29315==    by 0x5A92466: xdebug_lib_find_in_globals (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5AA3272: xdebug_should_ignore (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5AA3474: xdebug_debug_init_if_requested_at_startup (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5A8CBC0: ??? (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5A8D207: ??? (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x70C532: ??? (in /usr/local/bin/php)
==29315==    by 0x65EC9A: zend_call_function (in /usr/local/bin/php)
==29315==    by 0x571777: ??? (in /usr/local/bin/php)
==29315==    by 0x680961: zend_hash_apply (in /usr/local/bin/php)
==29315==    by 0x577165: php_call_shutdown_functions (in /usr/local/bin/php)
==29315==    by 0x601B14: php_request_shutdown (in /usr/local/bin/php)
==29315==  Address 0x9bad2a23 is not stack'd, malloc'd or (recently) free'd
==29315== 
==29315== 
==29315== Process terminating with default action of signal 11 (SIGSEGV)
==29315==  Access not within mapped region at address 0x9BAD2A23
==29315==    at 0x683652: zend_hash_str_find (in /usr/local/bin/php)
==29315==    by 0x5A92466: xdebug_lib_find_in_globals (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5AA3272: xdebug_should_ignore (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5AA3474: xdebug_debug_init_if_requested_at_startup (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5A8CBC0: ??? (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x5A8D207: ??? (in /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so)
==29315==    by 0x70C532: ??? (in /usr/local/bin/php)
==29315==    by 0x65EC9A: zend_call_function (in /usr/local/bin/php)
==29315==    by 0x571777: ??? (in /usr/local/bin/php)
==29315==    by 0x680961: zend_hash_apply (in /usr/local/bin/php)
==29315==    by 0x577165: php_call_shutdown_functions (in /usr/local/bin/php)
==29315==    by 0x601B14: php_request_shutdown (in /usr/local/bin/php)
==29315==  If you believe this happened as a result of a stack
==29315==  overflow in your program's main thread (unlikely but
==29315==  possible), you can try to increase the size of the
==29315==  main thread stack using the --main-stacksize= flag.
==29315==  The main thread stack size used in this run was 8388608.
==29315== 
==29315== HEAP SUMMARY:
==29315==     in use at exit: 3,302,609 bytes in 24,924 blocks
==29315==   total heap usage: 27,618 allocs, 2,694 frees, 4,148,865 bytes allocated
==29315== 
==29315== LEAK SUMMARY:
==29315==    definitely lost: 27,936 bytes in 873 blocks
==29315==    indirectly lost: 40 bytes in 1 blocks
==29315==      possibly lost: 2,210,586 bytes in 17,503 blocks
==29315==    still reachable: 1,064,047 bytes in 6,547 blocks
==29315==         suppressed: 0 bytes in 0 blocks
==29315== Rerun with --leak-check=full to see details of leaked memory
==29315== 
==29315== Use --track-origins=yes to see where uninitialised values come from
==29315== For lists of detected and suppressed errors, rerun with: -s
==29315== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
valgrind.log (4,859 bytes)   
Operating Systemalpine3.20.3 in docker on wsl2
PHP Version8.3.10-8.3.19

Relationships

has duplicate 0002294 resolvedderick Nette Tester always crashes in all test jobs when running with XDebug 3.4.0beta1 active 

Activities

RuggMatt

2024-11-21 21:26

reporter   ~0007082

xdebug.discover_client_host=true
xdebug.mode=debug
xdebug.start_with_request=trigger

derick

2024-11-27 15:36

administrator   ~0007083

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

derick

2024-11-27 16:26

administrator   ~0007099

Thanks for your report! This will be in the upcoming 3.4.0 release.

Issue History

Date Modified Username Field Change
2024-11-21 20:57 RuggMatt New Issue
2024-11-21 20:57 RuggMatt File Added: script.php
2024-11-21 20:57 RuggMatt File Added: gbd backtrace.txt
2024-11-21 20:57 RuggMatt File Added: valgrind.log
2024-11-21 21:26 RuggMatt Note Added: 0007082
2024-11-27 15:25 derick Assigned To => derick
2024-11-27 15:25 derick Status new => confirmed
2024-11-27 15:25 derick Target Version => 3.4dev
2024-11-27 15:35 derick Summary Segfault in 3.4.0beta => Segfault when checking whether to ignore creating a debug connection during shutdown functions
2024-11-27 15:36 derick Note Added: 0007083
2024-11-27 16:26 derick Status confirmed => closed
2024-11-27 16:26 derick Resolution open => fixed
2024-11-27 16:26 derick Fixed in Version => 3.4dev
2024-11-27 16:26 derick Note Added: 0007099
2024-11-28 13:17 derick Relationship added has duplicate 0002294
2024-11-28 13:41 derick Fixed in Version 3.4dev => 3.4.0