Xdebug Update: August 2019
This is another of the monthly update reports in which I explain what happened with Xdebug development in this past month. It will be published on the first Tuesday after the 5th of each month. Patreon supporters will get it earlier, on the first of each month. You can become a patron here to support my work on Xdebug. More supporters, means that I can dedicate more of my time to improving Xdebug.
In August, I worked on the following things:
2.8.0beta2 Release
This second beta release addresses a lot of issues that were still outstanding for the 2.8 release. This included simple issues like Wrong name displayed for Recoverable fatal errors and Code Coverage misses fluent interface function call. The trickiest bug was related to the DBGp debugging protocol.
I test Xdebug's implementation of the DBGp protocol by having a file with the PHP script to debug and then a phpt test that has a set of commands to run against that file. As an example, for one of the fixed bugs, the script looks like:
<?php
function breakpoint1()
{
echo base64_encode("testing"), "\n";
strlen();
}
breakpoint1();
?>
And the phpt test looks like:
<?php
require 'dbgp/dbgpclient.php';
$filename = realpath( dirname(__FILE__) . '/bug01388-01.inc' );
$commands = array(
'feature_get -n resolved_breakpoints',
"breakpoint_set -t line -f file://{$filename} -n 4",
'breakpoint_list',
'feature_set -n resolved_breakpoints -v 1',
'feature_get -n resolved_breakpoints',
'breakpoint_list',
"breakpoint_set -t line -f file://{$filename} -n 4",
'breakpoint_list',
'detach',
);
dbgpRunFile( $filename, $commands );
?>
The third command sets a breakpoint on line 4 (the echo statement) and then does various things related to breakpoint resolving. The "remote log" that is generated by the test is then compared (after some regexp replacements) with the expected output.
Because I run the script in a new process, I have some methods in place to also collect the output of the script (both stdout and stderr). I don't usually have stderr on, as there are a few false positives, but when I tested with this in the past, I noticed that one test caused a segmentation fault.
After a few hours of trying to find out the problem, I noticed that this would only happen in the init state (when the debugger first connects to the IDE, and when the IDE can enable features and send breakpoints). If in this init state the IDE would send the detach command, Xdebug would crash. This detach command can be used by an IDE to disengage the debugger, with the script continuing to run afterwards.
Due to an implementation bug related to whether the debugger connection was active or not, a detach in the init state would mark the connection active, while the connection was already cleaned up before hand. This caused Xdebug to access memory, that was already freed (which is a bad thing to do). The fix was luckily quite simple.
IANA Port Assignment
As a result of a twitter conversation that I had, I tried applying for an "assigned port" for the DBGp protocol. As some of you might be aware, Xdebug shares the same default port (9000) as PHP-FPM. This has caused confusion in the past, so I was hoping to avoid future problems with Xdebug 3 by asking IANA to assign me one. However, IANA declined by application by somewhat vague comments about "security" and not needing one because DBGp runs on a LAN.
As to the security aspect, they require authentication and encryption for new protocols, and of course DBGp isn't new. I would like to add an encryption layer to DBGp, but I can't require this right away, as that would mean no IDE can talk DBGp any more. Requiring authentication (i.e., username and password) would also prevent interoperability with current IDE implementations.
They also stipulated that I didn't need an assigned port due to the fact that most of the traffic runs on LANs only, and that there are other ways of negotiating a suitable port. All in all, neither requirement makes the use of Xdebug and DBGp easier.
Interestingly enough, they did write that it was "inappropriate" to use any currently assigned port—TCP/9000 is also used for cslistener. However, if they don't want to assign DBGp a port, than what am I supposed to do?
Towards release candidate 1
There is still one bug that I want to address for the first release candidate, and that is a long outstanding bug where Xdebug accesses variables passed into a function after PHP has already freed this information. I have created haphazard solutions in the past, but they never fully addressed the problem. They are hard to reproduce cases, and therefore I was happy to see a submitted pull request with test cases, and even a patch. The idea behind the patch is good, but only for one case, where the arguments are an object. The problem isn't only related to objects, and henceforth needs a more general solution. Nikita was happy to provide a suggested fix, which I will now have to put into practice.
Funding Xdebug
At the end of the month I started a thread on Twitter (now deleted) with the cheeky suggestion that I am considering making Xdebug non-free for commercial use. This is not something I would likely do, and instead would prefer to be funded through Patreon and commercial donations. The replies on the thread gave me a couple of ideas to make this more likely to work.
For companies it can often be complicated to use things like Patreon, as it's difficult for accounting or "selling it to management". I am therefore going to make it possible for companies to "buy a license", with a yearly invoice.
Another suggestion was to set up funding goals, which indicate how much time I can dedicate to working on Xdebug, with various levels of improvements. I have now done so on Patreon, with the following goals:
-
Maintain: I can dedicate enough time to Xdebug to continue supporting it in its current form, and making sure there is a new Xdebug version to complement new PHP versions. This might not necessarily include fixing all the more complicated bugs (Currently at 69%).
-
Feature: Not only will I have enough time to maintain Xdebug with newer PHP versions, but I will also be able to work on some requested features, and dive deeper into more complicated bugs (Currently at 34%).
-
Re-architect and performance: Besides maintenance and new features, I can now dedicate time to rewrite the parts of Xdebug that particularly slow, and re-architect it to be more much maintainable. The main reason for wanting to do that is performance, performance, and performance (Currently at 17%).
I will likely add these goals to the website as well, where I can also include company contributions. Let's see if we can get all of them to 100% together!
In order to make it easier to convince people to sign up, I am planning on making live coding sessions available to Patreon backers (of some higher levels), as well as providing commercial support for setting up Xdebug. These plans need a little bit more thought, so expect to hear from me about these in the near future.
Podcast
I have been continuing with the PHP Internals News podcast. In this weekly podcast, I discuss in 15-30 minutes, proposed new features to the PHP language with fellow PHP internals developers. It is available on Spotify and iTunes, and through an RSS Feed. Let me know if you are a listener!
Life Line
I've finished reading Children of Memory, the third book in the series.
Another interesting take on forms of intelligent life.
A fourth one is going to get released later this year.
Updated a post_box, a beauty shop, and a restaurant; Confirmed 2 clothes shops, 2 pet shops, and a restaurant
I walked 5.9km in 1h40m39s
Updated a bicycle_parking
Updated 2 waste_baskets
I walked 7.9km in 1h37m12s
Created 3 waste_baskets; Updated 3 bus_stops, 2 benches, and 2 waste_baskets
I walked 8.1km in 1h25m53s
I walked 1.2km in 9m31s
I walked 9.4km in 1h39m05s
Merge branch 'xdebug_3_5'
Merged pull request #1071
Fixed issue #2411: Native Path Mapping is not applied to the initial …
Created 2 waste_baskets; Updated 3 waste_baskets, 2 benches, and 2 other objects; Deleted a waste_basket
I walked 7.9km in 1h45m36s
RE: https://phpc.social/@phpc_tv/116274041642323081
Now that phpc.tv and phpc.social are part of the same umbrella, I've upped my yearly contributions to their Open Collective: https://opencollective.com/phpcommunity/projects/phpc-social
Merge branch 'xdebug_3_5'
Merged pull request #1070
I walked 7.2km in 1h10m26s
Fixed issue #2405: Handle minimum path in .xdebug directory discovery
I've published a new blog post: "Human Creations", on the difference in content generation by LLMs, and the creation of text, art and code by humans.
You can find it at https://derickrethans.nl/human-creations.html or at @blog
I walked 7.8km in 1h38m32s
RE: https://phpc.social/@afilina/116274024588235234
It's good to see that more and more people are realising that the Web can be for-good, without all the enshittification.
That's why I'm happy to see endeavours like phpc.tv springing up, and helping out where I can.
Taking back the control of how the Web is for people, by people, without big tech making it all shit.
Created a waste_basket; Updated 5 crossings and a bicycle_parking
I walked 10.7km in 2h35m10s


Shortlink
This article has a short URL available: https://drck.me/xdebug-19aug-ey4