View Issue Details

IDProjectCategoryView StatusLast Update
0001756XdebugStep Debuggingpublic2020-03-28 13:36
ReporterbarelAssigned Toderick 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformDockerOSMACOS Version10.13.6
Product Version2.9.2 
Target Version3.0.0devFixed in Version3.0.0dev 
Summary0001756: Php process won't exit after running connected to a client
DescriptionThis commit 37bfcc8a219a3ca88cb46f07a6404ce85e90fd84 (Re-add post-mortem checking for commands, and tweak tests) makes the php process not exit when running connected to a debugging client.


Steps To Reproduce- Enable an Xdebug client
- Run a php file from the command line by using `php file.php`
- After running the code, the process will not exit and you will need to hit CTL-C to finish it

I have traced the problem to this specific commit. My environment:
- MacOS 10.13.6
- PHP running within a docker environment (docker 2.2.0.0) with Alpine
- PHP version 7.1.20
- XDebug compiled with this commit, compiled with --enable-xdebug-dev (also happens with the non-dev version)

More info:
- Happens for any php code, it is not tied to the particular code that you are running
- php -v and php -i work fine and exit after outputting the info
TagsNo tags attached.
Operating System
PHP Version7.1.20-7.1.24

Activities

barel

2020-03-05 11:53

reporter   ~0005266

The debug client is PHPStorm

barel

2020-03-05 12:53

reporter   ~0005268

I am attaching here that remote log from one of the runs that failed to exit in case it helps

remote.log (4,247 bytes)

barel

2020-03-05 13:08

reporter   ~0005269

It is specifically this code change that creates the problem:

In handler_dbgp.c line 2240

- if ((XG_DBG(status) != DBGP_STATUS_RUNNING && (command->falgs & XDEBUG_DBGP_SYNC) == XDEBUG_DBGP_SYNC)
- || (XG_DBG(status) == DBGP_STATUS_RUNNING && (command->falgs & XDEBUG_DBGP_ASYNC) == XDEBUG_DBGP_ASYNC)
+ if (
+ (XG_DBG(status) != DBGP_STATUS_RUNNING && XG_DBG(status) != DBGP_STATUS_STOPPING && (command->flags & XDEBUG_DBGP_SYNC))
+ ||
+ (XG_DBG(status) == DBGP_STATUS_RUNNING && (command->flags & XDEBUG_DBGP_ASYNC))
+ ||
+ (XG_DBG(status) == DBGP_STATUS_STOPPING && (command->flags & XDEBUG_DBGP_POST_MORTEM))

derick

2020-03-21 20:13

administrator   ~0005315

I think I fixed something related with https://github.com/xdebug/xdebug/commit/7db9edee8935af9c51520572437aaed3dbeeae0d through 0001766

derick

2020-03-28 13:23

administrator   ~0005355

Hi,

I've now fixed this in Git, but, this turned out not to be an actual bug in Xdebug. It is rather a bug in PhpStorm, which would issue an extra 'run' command in the 'stopping' state. As 'run' is not valid, Xdebug replies with an error, but there is no reason why Xdebug should then abort the connection. Xdebug did do that *incorrectly* previously, so I suppose PhpStorm just came to rely on this behaviour. In https://xdebug.org/docs/dbgp#initiating-a-debugging-session, there is the text "Likewise, at the end of a debug session, there is a 'stopping' state. This state is entered after all execution is complete. For most debugger engine implementations, only a 'stop' command can be accepted at this point, however some implementations may provide additional commands for retrieving various data from the engine for post debug session processing." And for the "stop" command (https://xdebug.org/docs/dbgp#continuation-commands) it says "stop: ends execution of the script immediately, the debugger engine may not respond, though if possible should be designed to do so. The script will be terminated right away and be followed by a disconnection of the network connection from the IDE (and debugger engine if required in multi request apache processes)."

I'll lodge a report with the PhpStorm team, but for now, the workaround that I've just committed should do the trick for now.

cheers,
Derick

derick

2020-03-28 13:36

administrator   ~0005356

As reference: https://youtrack.jetbrains.com/issue/WI-51991

Issue History

Date Modified Username Field Change
2020-03-05 11:52 barel New Issue
2020-03-05 11:53 barel Note Added: 0005266
2020-03-05 12:53 barel File Added: remote.log
2020-03-05 12:53 barel Note Added: 0005268
2020-03-05 13:08 barel Note Added: 0005269
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:37 derick Category Variable Display => Step Debugging
2020-03-21 20:13 derick Note Added: 0005315
2020-03-23 11:08 derick Target Version => 3.0.0dev
2020-03-28 13:23 derick Assigned To => derick
2020-03-28 13:23 derick Status new => closed
2020-03-28 13:23 derick Resolution open => fixed
2020-03-28 13:23 derick Fixed in Version => 3.0.0dev
2020-03-28 13:23 derick Note Added: 0005355
2020-03-28 13:36 derick Note Added: 0005356