View Issue Details

IDProjectCategoryView StatusLast Update
0002144XdebugUncategorizedpublic2023-07-26 09:34
Reporterphysikbuddha Assigned Toderick  
PriorityurgentSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Target Version3.2devFixed in Version3.2.1 
Summary0002144: Xdebug 3.2.0 ignores xdebug.mode and enables all features
Description

Affected enviroment: Windows (haven't tried with *nix)
Affected Xdebug version: 3.2.0
Affected PHP version: All (I tried with PHP 8.1.0, 8.1.12, as well as the new 8.2.0)

I wanted to try out the new Xdebug 3.2.0 and installed it on my local machine.
I noticed that debugging got way slower after the update, so I did some testing:

At first some numbers: Executing a certain command (that is flushing the cache on a TYPO3 instance) took:

  • Without Xdebug: 7 seconds
  • With Xdebug 3.1.6: 20 seconds
  • With Xdebug 3.2.0: 1 minute, 15 seconds

I then noticed that my tmp directory was growing pretty fast, because every request I made caused Xdebug to output a profiling cachegrind file.
However, I didn't enable profiling in the first place. My xdebug.mode setting just contains "debug".

After some more testing, I came to the conclusion that Xdebug 3.2.0 almost completly ignores my xdebug.mode setting.
Setting it to "off" disables Xdebug like it should. However, setting it to any other value (including multiple values by comma separating them) enables every single feature.
This is what causes the great performance hit.

I attached two screenshots showing the output of xdebug_info(). Both versions were set to the same xdebug.mode value "debug".
But the enabled feature set is quite different.

Steps To Reproduce

Install Xdebug 3.2.0 with any PHP version you like (tried with 8.1.0, 8.1.12, 8.2.0) on Windows.
In php.ini, set xdebug.mode to debug.
Run xdebug_info() and take a look at the enabled features.

Additional Information

Minimal Xdebug configuration in php.ini to reproduce:

[XDebug]
zend_extension = path\to\php_xdebug-3.2.0-8.2-vs16-x86_64.dll
xdebug.mode = debug

TagsNo tags attached.
Attached Files
Operating SystemWindows 10 Pro 22H2
PHP Version8.1.10-8.1.19

Relationships

has duplicate 0002149 resolvedderick Stack Traces are shown even when xdebug is running in mode 'debug' 
has duplicate 0002165 resolvedderick xdebug.profiler_output_name files created even if xdebug.mode profile is not set 
has duplicate 0002152 resolvedderick Can't get HTML formatted errors to enable 
has duplicate 0002145 resolvedderick Xdebug 3.2.0 crash PHP on Windows if xdebug.mode = off 

Activities

derick

2022-12-12 09:37

administrator   ~0006474

Hi,

I can't seem to reproduce this with Linux and PHP's built-in web server.

What is your set up? Do you use Apache, or IIS, or something else? Could you try with PHP's built-in web server?

I ran my test as follows, on a command prompt:

php -n -d xdebug.mode=debug -d zend_extension=xdebug -S localhost:9242

You might have to change paths. The -n disables all ini settings

And then opened http://localhost:9242/info.php in my browser, which contained only a call to xdebug_info().

I will have a look later on Windows, but it would help me if you let me know more about your setup.

cheers,
Derick

physikbuddha

2022-12-12 10:21

reporter   ~0006477

Okay, so I can confirm that it's working just fine with the PHP integrated webserver (like it should).

The error occurred on a standard XAMPP installation (that I was using as a quick development server).

These are the minimal steps to reproduce it:

  • Download the current (8.1.12) version at https://www.apachefriends.org/de/index.html

  • Install it to the default directory C:\xampp and uncheck every feature you can (we just need Apache and PHP; you can't uncheck them)

  • Copy php_xdebug-3.1.6-8.1-vs16-x86_64.dll and php_xdebug-3.2.0-8.1-vs16-x86_64.dll to C:\xampp\php\ext

  • Edit C:\xampp\php\php.ini and add:
    [XDebug]
    zend_extension = C:\xampp\php\ext\php_xdebug-3.2.0-8.1-vs16-x86_64.dll
    xdebug.mode = debug

  • Remove everything in C:\xampp\php\htdocs and add a xdebug.php containing:
    <?php
    xdebug_info();

  • Run Apache from the Control Panel or by executing C:\xampp\apache_start.bat

  • Open http://localhost/xdebug.php

  • All Xdebug features are enabled (but they shouldn't)

  • Optional: Stop Apache, change the xdebug extension to 3.1.6 in php.ini - the Xdebug feature list will only show the Step Debugger now

physikbuddha

2022-12-12 10:22

reporter   ~0006478

So maybe I should report this to the Apache foundation then?

But I wonder why this error didn't occur before. I was able to use Xdebug with a standard XAMPP installation for years just fine.

physikbuddha

2022-12-12 10:23

reporter   ~0006479

Apache Friends, not Apache foundation.

(Sorry, I can't seem to edit my comments here).

derick

2022-12-18 15:50

administrator   ~0006493

Hi,

I have tried this now, and I can indeed reproduce this. I think I also have a vague idea where and why this happens. The problem is is that I don't know how to debug this properly on Windows, so I am going to have to see if I can reproduce this on Linux. But now I know what the issue could be, that is easier.

You don't need to report this to the Apache Friends people.

cheers,
Derick

AnrDaemon

2022-12-20 21:02

reporter   ~0006495

I've stumbled upon it on CentOS 7.9.2009 with latest PHP and XDebug from remi-php80.
Comparing my older VM with a newly deployed one,

[code]
-<tr><td class="e">Development Helpers</td><td class="v">[x] disabled</td><td class="d"><a href="https://xdebug.org/docs/develop"></a></td></tr>
+<tr><td class="e">Development Helpers</td><td class="v">[v] enabled</td><td class="d"><a href="https://xdebug.org/docs/develop"></a></td></tr>
-<tr><td class="e">Step Debugger</td><td class="v">[v] enabled</td><td class="d"><a href="https://xdebug.org/docs/remote"></a></td></tr>
+<tr><td class="e">Step Debugger</td><td class="v">[x] disabled</td><td class="d"><a href="https://xdebug.org/docs/remote"></a></td></tr>
+<tr><td class="e">'xdebug://gateway' pseudo-host support </td><td class="v">yes </td></tr>
+<tr><td class="e">'xdebug://nameserver' pseudo-host support </td><td class="v">yes </td></tr>
-<tr><td class="e">xdebug.client_discovery_header</td><td class="v">no value</td><td class="v">no value</td></tr>
+<tr><td class="e">xdebug.client_discovery_header</td><td class="v">HTTP_X_FORWARDED_FOR,REMOTE_ADDR</td><td class="v">HTTP_X_FORWARDED_FOR,REMOTE_ADDR</td></tr>
[/code]

P.S.
Please fix collation on database tables.
Database query failed. Error received from database was 0001366: Incorrect string value: '\xE2\x9C\x98 di...' for column bugs.mantis_bugnote_text_table.note at row 1 for the query: INSERT INTO mantis_bugnote_text_table ( note ) VALUES ( ? ).

derick

2022-12-21 10:46

administrator   ~0006496

@AnrDaemon — I'd love to fix the collation, but the last time I tried I ended up messing everything up. Don't really want to do that again.

In any case, what is the web server setup that you use? Apache? Which MPM? Something else?

AnrDaemon

2022-12-21 20:34

reporter   ~0006498

nginx, php-fpm, socket.
Trivial by-the-books setup with

        location ~ ^/.+\.php$ {
                include fastcgi.conf;
                fastcgi_index index.php;
                fastcgi_pass unix:/var/run/xxx.sock;
                fastcgi_read_timeout 180s;
        }

AnrDaemon

2023-01-27 14:17

reporter   ~0006507

Any update on the issue? Sorry to bother, but manually installing 3.1 from PECL is very inconvenient on package managed systems.

derick

2023-01-27 14:25

administrator   ~0006508

No update, I can't reproduce this.

kAlvaro

2023-02-12 09:32

reporter   ~0006515

Whatever is it, is isn't related to php-fpm because it also happens with mod_php.

AnrDaemon

2023-03-04 16:09

reporter   ~0006516

Derick, what kind of reproduction setup you would accept to evaluate this issue? Docker, LXD, ovirt?

derick

2023-03-04 16:22

administrator   ~0006517

Docker would be fine, preferably with the container having debug builds of PHP and Xdebug and with gdb and valgrind installed.

AnrDaemon

2023-03-04 18:14

reporter   ~0006518

If you have a readily available Dockerfile with these tools, it would help greatly.

derick

2023-03-07 11:45

administrator   ~0006519

Sorry, I don't have a Dockerfile with these tools yet — but it's usually not hard to add them (apt-get install valgrind gdb strace) so no sweat if your repo case wouldn't have them.

derick

2023-03-13 14:12

administrator   ~0006521

@AnrDaemon I just tried to reproduce this again with PHP 8.2.5 and both ZTS and NTS versions of PHP-FPM with Xdebug 3.2.0, and I see no problems. If you have any sort of Docker environment that can reproduce this, that would be most welcome!

Otomatic

2023-03-20 16:49

reporter   ~0006529

xdebug_mode_off.png (122,931 bytes)   
xdebug_mode_off.png (122,931 bytes)   
xdebug_mode_develop.png (124,718 bytes)   
xdebug_mode_develop.png (124,718 bytes)   

derick

2023-03-20 18:01

administrator   ~0006531

I have just made a PR to fix this bug, which as far as I can tell only occurred in threaded environments:

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


If you're on Linux and can compile Xdebug yourself to test, please use this branch: https://github.com/derickr/xdebug/tree/issue2144-mode-in-threaded-environment

If you're on Windows, please use one of the new DLLs (called Artifacts) https://github.com/xdebug/xdebug/actions/runs/4471304815?pr=881#artifacts — You'll likely need the ones that don't have "nts" in their filename.

Otomatic

2023-03-21 11:33

reporter   ~0006532

It is OK now with 3.2.1 dev TS on PHP 8.2.4 - Thanks

xdebug_mode_develop3.2.1.png (113,609 bytes)   
xdebug_mode_develop3.2.1.png (113,609 bytes)   

derick

2023-03-21 16:27

administrator   ~0006533

https://github.com/xdebug/xdebug/pull/875 — which is now merged, and 3.2.1 will be released soon.

AnrDaemon

2023-07-25 14:48

reporter   ~0006606

Turned out, in my case it was more a reading documentation issue.
In modern xdebug, mode can not be set in FPM configuration.
Which is bad. I do not want to have, say, profiler enabled for all sites.
Nor do I want to have a zillion of different FPM daemons running with the same PHP version, even though it is somewhat trivial with modern systemd.

derick

2023-07-26 09:34

administrator   ~0006607

@AnrDaemon — I know it is annoying. Unfortunately it isn't something I can relax right now, due to the way how PHP-FPM initialises PHP and its extensions. Xdebug (and likely other extensions) rely on the hooks being set-up right, and once, depending on an authoritative value of options (xdebug.mode in our case). PHP-FPM allows ini settings to be overridden after extensions have been initialised (it starts PHP once, and the forks for each worker, which then can have different values), which is a no-no for Xdebug.

Issue History

Date Modified Username Field Change
2022-12-11 14:41 physikbuddha New Issue
2022-12-11 14:41 physikbuddha File Added: 2022-12-11 15_22_11-Xdebug 3.1.6.png
2022-12-11 14:41 physikbuddha File Added: 2022-12-11 15_23_13-Xdebug 3.2.0.png
2022-12-12 09:37 derick Assigned To => derick
2022-12-12 09:37 derick Status new => feedback
2022-12-12 09:37 derick Note Added: 0006474
2022-12-12 10:21 physikbuddha Note Added: 0006477
2022-12-12 10:21 physikbuddha Status feedback => assigned
2022-12-12 10:22 physikbuddha Note Added: 0006478
2022-12-12 10:23 physikbuddha Note Added: 0006479
2022-12-18 15:50 derick Note Added: 0006493
2022-12-18 15:50 derick Priority normal => urgent
2022-12-18 15:50 derick Severity major => crash
2022-12-18 15:50 derick Status assigned => confirmed
2022-12-18 15:50 derick Target Version => 3.2dev
2022-12-20 21:02 AnrDaemon Note Added: 0006495
2022-12-21 10:46 derick Status confirmed => feedback
2022-12-21 10:46 derick Note Added: 0006496
2022-12-21 10:47 derick Relationship added has duplicate 0002149
2022-12-21 20:34 AnrDaemon Note Added: 0006498
2023-01-27 14:17 AnrDaemon Note Added: 0006507
2023-01-27 14:25 derick Note Added: 0006508
2023-02-12 09:32 kAlvaro Note Added: 0006515
2023-03-04 16:09 AnrDaemon Note Added: 0006516
2023-03-04 16:22 derick Note Added: 0006517
2023-03-04 18:14 AnrDaemon Note Added: 0006518
2023-03-07 11:45 derick Note Added: 0006519
2023-03-13 14:12 derick Note Added: 0006521
2023-03-20 16:49 Otomatic Note Added: 0006529
2023-03-20 16:49 Otomatic File Added: xdebug_mode_off.png
2023-03-20 16:49 Otomatic File Added: xdebug_mode_develop.png
2023-03-20 17:41 derick Relationship added has duplicate 0002165
2023-03-20 18:01 derick Status feedback => confirmed
2023-03-20 18:01 derick Note Added: 0006531
2023-03-21 11:33 Otomatic Note Added: 0006532
2023-03-21 11:33 Otomatic File Added: xdebug_mode_develop3.2.1.png
2023-03-21 16:26 derick Status confirmed => closed
2023-03-21 16:26 derick Resolution open => fixed
2023-03-21 16:26 derick Fixed in Version => 3.2dev
2023-03-21 16:27 derick Note Added: 0006533
2023-03-21 16:29 derick Relationship added has duplicate 0002152
2023-03-21 16:30 derick Fixed in Version 3.2dev => 3.2.1
2023-03-21 16:32 derick Relationship added has duplicate 0002145
2023-07-25 14:48 AnrDaemon Note Added: 0006606
2023-07-26 09:34 derick Note Added: 0006607