View Issue Details

IDProjectCategoryView StatusLast Update
0002307XdebugUncategorizedpublic2024-12-21 21:18
Reportereveryman Assigned Toderick  
PriorityurgentSeveritycrashReproducibilityalways
Status confirmedResolutionfixed 
Product Version3.4.0 
Target Version3.4devFixed in Version3.4dev 
Summary0002307: Segmentation fault due to a superglobal being a reference while checking for triggers
Description

Due to the integration of Xdebug 3.4.0 in PHP 8.3.14 (but also with PHP 8.4.1), the following PHP script causes a segmentation fault of the Apache server process when the PHP script is terminated after a reference to a superglobal was created and a shutdown function was available.

Steps To Reproduce

Due to the integration of Xdebug 3.4.0 in PHP 8.3.14 (but also in PHP 8.4.1), the following PHP script causes a segmentation fault of the Apache server process when the script is ending:

<?php
echo "bla";
$fasel = &$_GET;
register_shutdown_function(function () { echo "shutdown"; });

[Tue Dec 03 12:27:02.721336 2024] [core:notice] [pid 8081:tid 8081] AH00052: child pid 8162 exit signal Segmentation fault (11)

It does not matter whether an active debugger session is running or not. It is important that both the assignment of a reference to a superglobal and the registration of a shutdown function must be present in the PHP script.

Aufgefallen ist es mir zurerst in einer PHP 8.4.1 und Xdebug 3.4.0 Umgebung. Das entfernen des Xdebug-Extension hatte das Problem behoben. Genauso hat es sich mit einer PHP 8.3.14 und Xdebug 3.4.0 verhalten. Ein PHP 8.3.14 und Xdebug 3.3.2 zeigt das Problem nicht.

I first noticed it in a PHP 8.4.1 and Xdebug 3.4.0 environment. Removing the Xdebug extension solved the problem. The same happened with PHP 8.3.14 and Xdebug 3.4.0. A PHP 8.3.14 and Xdebug 3.3.2 does not show the problem.

Additional Information

This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.3.14, Copyright (c) Zend Technologies with Zend OPcache v8.3.14, Copyright (c), by Zend Technologies with Xdebug v3.4.0, Copyright (c) 2002-2024, by Derick Rethans

Tagssegfault
Operating SystemWindows 11 Docker-Desktop - Container - Debian bookworm - Linux 26d71de58aa9 6.10.14-linuxkit #1 SMP PREEMPT_DYNAMIC Thu Oct 24 19:30:56 UTC 2024 x86_64 GNU/Linux
PHP Version8.3.10-8.3.19

Relationships

has duplicate 0002306 resolvedderick Segmentation fault on each HTTP request when not listening to debugging connections 
has duplicate 0002310 resolvedderick xdebug 3.4.0 crashes php8.1-fpm after script execution 

Activities

mtassinari

2024-12-04 10:01

reporter   ~0007112

I think the bug I reported (https://bugs.xdebug.org/view.php?id=2306) might be related with this; in fact, in our webapp, we do get references to the superglobals at the very beginning of the request cycle.

However, in my case, there is not shutdown function registered, and the segfault happens only when the debugging session is not actually started.

derick

2024-12-13 17:21

administrator   ~0007115

I can trivially reproduce this. Thanks for the short and succint report!

derick

2024-12-13 17:39

administrator   ~0007116

This turned out to be a similar issue than 0002305 — at least it has the same cause.

I have made a PR: https://github.com/xdebug/xdebug/pull/986

Would you be able to check the xdebug_3_4 branch from Xdebug's Github (once it's merged)?

langemeijer

2024-12-17 15:33

reporter   ~0007123

I also ran into this issue, using xdebug 3.4.0 on 8.3 and 8.4. Using xdebug latest master branch solved this issue. Thank you Derick, happy holidays.

langemeijer

2024-12-17 16:35

reporter   ~0007124

Although this changes solves most issues, I have to add that this is not the only cause of segmentation faults in 3.4.0. This snippet of code still causes a segfault:

<?php
echo "bla";
$fasel = &$_GET;

set_exception_handler(static function () {
echo '1';
});

require_once '_non_existing_file';

everyman

2024-12-17 18:23

reporter   ~0007125

I have checked out the xdebug_3_4 branch and added the compiled xdebug of a PHP 8.4. The problem can no longer be reproduced with this version.

This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.4.1, Copyright (c) Zend Technologies with Zend OPcache v8.4.1, Copyright (c), by Zend Technologies with Xdebug v3.4.1-dev, Copyright (c) 2002-2024, by Derick Rethans

everyman

2024-12-17 18:28

reporter   ~0007126

I can confirm https://bugs.xdebug.org/view.php?id=2307#c7124 with a similar variant:

--- test2.php
<?php
echo "a"b"; # PHP-Syntax-Error

--- test1.php
<?php
$get = &$_GET;
function bla(Throwable $exception) {
echo "fasel";
}
set_exception_handler("bla");
include "test2.php";

Calling test1.php with a PHP 8.4 and Xdebug v3.4.1-dev also returns a segmentation fault.

derick

2024-12-20 16:23

administrator   ~0007128

It seemed that I fixed a symptom, and not the actual issue, which is: Segmentation fault due to a superglobal being a reference

derick

2024-12-20 16:24

administrator   ~0007129

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

derick

2024-12-20 16:37

administrator   ~0007131

I've merged the PR. It would be great if you could have a check/look again!

langemeijer

2024-12-21 21:18

reporter   ~0007132

All seems fine with the last revision. Thank you Derick.

Issue History

Date Modified Username Field Change
2024-12-03 12:48 everyman New Issue
2024-12-04 10:01 mtassinari Note Added: 0007112
2024-12-04 15:49 mtassinari Tag Attached: segfault
2024-12-13 17:21 derick Assigned To => derick
2024-12-13 17:21 derick Status new => confirmed
2024-12-13 17:21 derick Note Added: 0007115
2024-12-13 17:22 derick Target Version => 3.4dev
2024-12-13 17:39 derick Summary Segmentation fault if shutdown and reference to a superglobal is generated => Segmentation fault during shutdown and checking for triggers
2024-12-13 17:39 derick Note Added: 0007116
2024-12-13 17:40 derick Relationship added has duplicate 0002306
2024-12-13 17:57 derick Status confirmed => closed
2024-12-13 17:57 derick Resolution open => fixed
2024-12-13 17:57 derick Fixed in Version => 3.4dev
2024-12-17 15:33 langemeijer Note Added: 0007123
2024-12-17 16:35 langemeijer Note Added: 0007124
2024-12-17 18:23 everyman Note Added: 0007125
2024-12-17 18:28 everyman Note Added: 0007126
2024-12-20 16:23 derick Status closed => confirmed
2024-12-20 16:23 derick Note Added: 0007128
2024-12-20 16:24 derick Summary Segmentation fault during shutdown and checking for triggers => Segmentation fault due to a superglobal being a reference while checking for triggers
2024-12-20 16:24 derick Note Added: 0007129
2024-12-20 16:25 derick Relationship added has duplicate 0002310
2024-12-20 16:37 derick Note Added: 0007131
2024-12-21 21:18 langemeijer Note Added: 0007132