Contributing Advent 23: Reproducing issues
Many users that find flaws in software will just shrug and find a workaround, some will provide a cryptic bug report, but very few will actually write a coherent bug report that makes it very clear as to how to reproduce an issue. Without a reproducible case, it can be very tricky to find the bug, and then subsequently fix it.
If people encounter bugs in Xdebug's remote debugging I very often ask them to produce a remote log file. This log file will contain the communication packets between Xdebug and the IDE. In some cases, this highlights that an IDE did something wrong, or perhaps there is a misconfiguration (often with path mappings!). Together with the script that was used to create a log it is often very simple for me to reproduce the issue, and then fix it.
However, sometimes I get a bug report that goes along "the massive Symfony application causes an issue". I can not do anything with that. Even though it might be easy to reproduce (1. install Symfony, 2. install application, 3. run massive PHPUnit test suite), I do not have the time (and knowledge) to debug any random PHP application. As a user of the Open Source software that would like a bug fixed, you should spend some time making it easy for the developers of said software to figure out the problem. That means that you need to dissect your massive Symfony application and produce a small script that shows the behaviour. If possible, this script should also never rely on external resources such as a database, or some SOAP service.
A reproducible issue is also one that you can reliably trigger. That means hitting a single URL or executing a single script on the command line. With PHP or PHP extensions such as Xdebug there are sometimes issues that only show up once in a while, because memory corruption do not always result in crashes. A few tools are available to more easily highlight those issues.
In almost every case, you would want to set the environment variable export
USE_ZEND_ALLOC=0. Zend's memory allocator can sometimes hide issues because of "clever" memory management, and by making PHP use the standard OS memory management routines issues can show up earlier. Setting this environment variable is especially important if you also use the second tool: Valgrind.
Valgrind is a memory debugging tool which helps me find things like using uninitialised memory, memory that is already freed, writing out of bounds or memory leaks. It is an unmissable tool for me in very many cases. Providing a Valgrind log with a bug report is very helpful.
Valgrind is only useful if you have PHP and Xdebug compiled in debug mode. If you use PHP from a Linux distribution's package you should install something like php5-dev or php5-devel to also have the debugging symbols available. For Xdebug you would need to compile it yourself (and not use PECL, or a distribution's package).
In some cases, memory leaks and errors show up only when PHP or an extension is shutdown. If an extension is already unloaded, then Valgrind can not pinpoint exactly where in the code the issue occurred. If this happens, you see lines with ??? in the output. By setting yet another environment variable, you prevent PHP from unloading the module. This environment variable is: export ZEND_DONT_UNLOAD_MODULES=1. With both USE_ZEND_ALLOC=0 and ZEND_DONT_UNLOAD_MODULES=1 set, Valgrind gives the best results. And a bug where Valgrind shows that Xdebug (or something else) does something wrong is the best kind you can file!
Life Line
π· Tufted Duck Pair
π© Outer Circle, City of Westminster, United Kingdom
RE: https://phpc.social/@Xdebug/115662135830755552
I have just released Xdebug 3.5.0!
In the next few weeks I will create some content (text, and perhaps video) highlighting some new features in more detail.
Please share it with the world!
The master branch is now for Xdebug 3.6, targetting PHP 8.6
Back to -dev
Tweak release instructions a little
Go with 3.5.0
Tweak message IDs and severities for control socket log entries
I walked 8.5km in 1h30m56s
My whisky of the month for December 2025, is a 15yo Aultmore bottled by Cadenhead's.
Fixed off-by-one error in address length name for control socket on Lβ¦
Merged pull request #1050
Fixed control socket name by removing silly trailing things (by not pβ¦
RE: https://en.osm.town/@harry_wood/115650834037247679
Fancy a friendly #OpenStreetMap chat in the pub, with some Christmas celebrations?
The London OSM gang is meeting on December 16th near Paddington.
I walked 8.7km in 1h29m30s
RE: https://mastodon.online/@afup/115648919275171255
This talk on what's New in PHP 8.5 is in English! Je ne parles pas FranΓ§ais!
I walked 10.0km in 1h46m14s
Merged pull request #1049
Reorder xdfree(name) and removing trailing whitespace
Tweak comments to use /* .. */ style
Reuse created \\.\pipe name


Shortlink
This article has a short URL available: https://drck.me/adv1323-afl