View Issue Details

IDProjectCategoryView StatusLast Update
0002059XdebugStep Debuggingpublic2022-06-06 15:22
Reporterldschaak Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version3.1.2 
Summary0002059: XDebug always activated without trigger when idekey and XDEBUG_CONFIG is set at the same time
Description

As the title says i stumbled upon the problem, that XDebug is enabled at every request, even if there is no trigger.

I got the problem on a project where i use a third party docker image, where xdebug.idekey setting has a non-empty value.
At our docker-compose setting we set and ENV variable for the XDEBUG_CONFIG to mode=develop,debug

This two settings in combination shows us a warning in every console command we are using:
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(

To go to the root of the problem, i used docker to make an reproduceable example.

As far as i can see this behaviour can not be overwritten by xdebug.start_with_request=trigger.
On the other hand, xdebug.start_with_request=off works as expected and disables XDebug completely.

Steps To Reproduce

$ docker run -it --rm php:8.0 bash

$ pecl install xdebug
$ docker-php-ext-enable xdebug

With the following command i expect to see no warning, because XDebug remote connection should not be established.
$ XDEBUG_CONFIG="" php -n -dzend_extension=xdebug -dxdebug.mode=debug -dxdebug.idekey="asdf" -r "var_dump(xdebug_is_debugger_Active());"
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
bool(false)

For other combinations i have following output, were XDebug works a expected:

idekey: not set, XDEBUG_CONFIG: not set
$ php -n -dzend_extension=xdebug -dxdebug.mode=debug -dxdebug.idekey="" -r "var_dump(xdebug_is_debugger_Active());"
bool(false)

idekey: set, XDEBUG_CONFIG: not set
$ php -n -dzend_extension=xdebug -dxdebug.mode=debug -dxdebug.idekey="asdf" -r "var_dump(xdebug_is_debugger_Active());"
bool(false)

idekey: not set, XDEBUG_CONFIG: set
$ XDEBUG_CONFIG="" php -n -dzend_extension=xdebug -dxdebug.mode=debug -dxdebug.idekey="" -r "var_dump(xdebug_is_debugger_Active());"
bool(false)

Additional Information

$ php -v
PHP 8.0.15 (cli) (built: Jan 20 2022 20:08:16) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.15, Copyright (c) Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans

$ uname -srm
Linux 5.4.0-96-generic x86_64

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

TagsNo tags attached.
Operating SystemDebian
PHP Version8.0.0-8.0.4

Relationships

duplicate of 0002070 resolvedderick xdebug.start_with_request=trigger not working, starts all the time 

Activities

derick

2022-01-26 20:12

administrator   ~0006196

I can reproduce this locally, without docker, with:

<pre>
XDEBUG_CONFIG="" php -n -dzend_extension=xdebug -dxdebug.mode=debug -dxdebug.idekey="asdf" -r "var_dump(xdebug_is_debugger_Active());"
</pre>

derick

2022-03-11 17:57

administrator   ~0006242

This is a duplicate of 0002070, which I have investigated and deemed as "working as expected": https://bugs.xdebug.org/2070#c6238

ldschaak

2022-03-14 07:57

reporter   ~0006244

Thanks for your answer. I appreciate the update of the docs!

We will try to use XDEBUG_CONFIG furthermore, because it's a nice and easy way to configure docker images from outside without changing the actual image.

derick

2022-03-14 09:38

administrator   ~0006245

I think there is a different (better?) way of doing that. Instead of using XDEBUG_CONFIG, you can make a XDEBUG_CLIENT_HOST environment variable in your docker-compose.yml file:

services:
  php:
    build:
      dockerfile: ${PWD}/.devcontainer/Dockerfile
    image: php-fpm
    environment:
      XDEBUG_MODE: ${XDEBUG_MODE}
      XDEBUG_CLIENT_HOST: ${XDEBUG_CLIENT_HOST}

And then in your php.ini/xdebug.ini, use that created environment variable as well. This is described at https://www.php.net/manual/en/configuration.file.php#example-27:

[xdebug]
xdebug.client_host=${XDEBUG_CLIENT_HOST}

Growiel

2022-03-24 09:53

reporter   ~0006250

That workaround is more or less exactly what I switched to following my last ticket. Can confirm it works.

Issue History

Date Modified Username Field Change
2022-01-26 15:24 ldschaak New Issue
2022-01-26 20:12 derick Assigned To => derick
2022-01-26 20:12 derick Status new => confirmed
2022-01-26 20:12 derick Note Added: 0006196
2022-01-26 20:12 derick Target Version => 3.1dev
2022-03-11 17:57 derick Status confirmed => resolved
2022-03-11 17:57 derick Resolution open => no change required
2022-03-11 17:57 derick Note Added: 0006242
2022-03-11 17:57 derick Relationship added duplicate of 0002070
2022-03-14 07:57 ldschaak Note Added: 0006244
2022-03-14 09:38 derick Note Added: 0006245
2022-03-24 09:53 Growiel Note Added: 0006250
2022-06-06 15:22 derick Target Version 3.1dev =>