View Issue Details

IDProjectCategoryView StatusLast Update
0002211XdebugStep Debuggingpublic2023-11-30 14:50
ReporterZobo Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.2.2 
Fixed in Version3.3.0 
Summary0002211: File wrappers get wrong filename location in stack.
Description

I was researching this issue https://github.com/xdebug/vscode-php-debug/issues/931 that caused a crash with Xdebug 3.1 and ran into a strange situation. The user describes that they are using laravel/serializable-closure . Not to bore you with details, this packages uses a custom stream wrapper to store the body of a closure and then include it for execution. The problem that I found is that Xdebug reports an invalid path in the stack trace. I was able to make a very small script to reproduce it. I used the built in data:// stream wrapper to avoid extra code.

Steps To Reproduce

You need to set -ddallow_url_include=1

<?php

function f2() { debug_print_backtrace(); }
$data = "data://text/plain;base64,".base64_encode("<"."?php\nreturn function() {\nf2();\nxdebug_break();\nreturn 'XXXX';\n};");
$f = include($data);
$f();

Note, I added f2() function so i could show the output of debug_print_backtrace()

#0 data://text/plain;base64,PD9waHAKcmV0dXJuIGZ1bmN0aW9uKCkgewpmMigpOwp4ZGVidWdfYnJlYWsoKTsKcmV0dXJuICdYWFhYJzsKfTs=(3): f2()
#1 C:\local_disk\zobo\Projects\vscode-php-debug\TEST\closures\test2.php(6): {closure}()

run -i 12
<?xml version="1.0" encoding="iso-8859-1"?><response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug&quot; command="run" transaction_id="12" status="break" reason="ok"><xdebug:message filename="file://C:/local_disk/zobo/Projects/vscode-php-debug/TEST/closures/data:/text/plain;base64,PD9waHAKcmV0dXJuIGZ1bmN0aW9uKCkgewpmMigpOwp4ZGVidWdfYnJlYWsoKTsKcmV0dXJuICdYWFhYJzsKfTs=" lineno="5"></xdebug:message></response>

stack_get -i 13
<?xml version="1.0" encoding="iso-8859-1"?><response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug&quot; command="stack_get" transaction_id="13"><stack where="{closure:data://text/plain;base64,PD9waHAKcmV0dXJuIGZ1bmN0aW9uKCkgewpmMigpOwp4ZGVidWdfYnJlYWsoKTsKcmV0dXJuICdYWFhYJzsKfTs=:2-6}" level="0" type="file" filename="file://C:/local_disk/zobo/Projects/vscode-php-debug/TEST/closures/data:/text/plain;base64,PD9waHAKcmV0dXJuIGZ1bmN0aW9uKCkgewpmMigpOwp4ZGVidWdfYnJlYWsoKTsKcmV0dXJuICdYWFhYJzsKfTs=" lineno="5"></stack><stack where="{main}" level="1" type="file" filename="file:///C:/local_disk/zobo/Projects/vscode-php-debug/TEST/closures/test2.php" lineno="6"></stack></response>

Additional Information

I think Xdebug should return
filename="data://text/plain;base64,PD9waHAKcmV0dXJuIGZ1bmN0aW9uKCkgewpmMigpOwp4ZGVidWdfYnJlYWsoKTsKcmV0dXJuICdYWFhYJzsKfTs="
instead of
filename="file://C:/local_disk/zobo/Projects/vscode-php-debug/TEST/closures/data:/text/plain;base64,PD9waHAKcmV0dXJuIGZ1bmN0aW9uKCkgewpmMigpOwp4ZGVidWdfYnJlYWsoKTsKcmV0dXJuICdYWFhYJzsKfTs="

Good question what a IDE could do with this....

Ideally if would return filename="dbgp://..." but then this means it would need to store the content somewhere - like with eval()

TagsNo tags attached.
Operating Systemwin/linux
PHP Version8.2.0-8.2.9

Activities

Zobo

2023-11-09 14:33

reporter   ~0006677

Or maybe DBGP source could be used regrades? I need to test.
source -i 1 -f data://text/plain;base64,PD9waHAKcmV0dXJuIGZ1bmN0aW9uKCkgewpmMigpOwp4ZGVidWdfYnJlYWsoKTsKcmV0dXJuICdYWFhYJzsKfTs=

Zobo

2023-11-15 17:52

reporter   ~0006678

This actually does work!

image.png (19,814 bytes)   
image.png (19,814 bytes)   
image-2.png (31,212 bytes)   
image-2.png (31,212 bytes)   

Zobo

2023-11-15 23:32

reporter   ~0006679

Proposing fix https://github.com/xdebug/xdebug/pull/921

Issue History

Date Modified Username Field Change
2023-11-09 14:27 Zobo New Issue
2023-11-09 14:33 Zobo Note Added: 0006677
2023-11-15 17:52 Zobo Note Added: 0006678
2023-11-15 17:52 Zobo File Added: image.png
2023-11-15 17:52 Zobo File Added: image-2.png
2023-11-15 23:32 Zobo Note Added: 0006679
2023-11-30 10:41 derick Assigned To => derick
2023-11-30 10:41 derick Status new => closed
2023-11-30 10:41 derick Resolution open => fixed
2023-11-30 10:41 derick Fixed in Version => 3.3dev
2023-11-30 14:50 derick Fixed in Version 3.3dev => 3.3.0