Valgrinding shared modules
Over the past year I've been writing various commercial (more about that later) and open source PHP extensions (such as QuickHash, more about that later too). Most of the time they are shared extensions that are not part of PHP. While testing whether I correctly free all memory with Valgrind, I ran into the issue where I couldn't see the stack frames of where the memory leaks occurred in the extensions, and once I even ran into a Valgrind bug. The reason why Valgrind could not show the function names belonging to the stack frames is because PHP had already unloaded the shared extensions from memory.
I often found myself compiling the extensions into PHP statically so that there was nothing to unload for PHP, but that was becoming annoying. So instead I added a patch to PHP that prevents the shutdown sequence from actually unloading the modules. You can trigger this behaviour by setting the ZEND_DONT_UNLOAD_MODULES environment variable before running your script:
# export ZEND_DONT_UNLOAD_MODULES=1 # valgrind --leak-check=full --show-reachable=yes php -r 'echo "Hello World\n";'
Without ZEND_DONT_UNLOAD_MODULES exported, my Valgrind output shows a block like:
# unset ZEND_DONT_UNLOAD_MODULES # valgrind --leak-check=full --show-reachable=yes php -r 'echo "Hello World\n";' ... ==25829== 8 bytes in 1 blocks are indirectly lost in loss record 2 of 21 ==25829== at 0x4C25E84: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==25829== by 0xCE440DC: ??? ==25829== by 0xCE44316: ??? ==25829== by 0xCE44368: ??? ==25829== by 0xCBEE55F: ??? ==25829== by 0xCBD3F87: ??? ==25829== by 0x949A85: zend_activate_modules (zend_API.c:2285) ==25829== by 0x8B5EBC: php_request_startup (main.c:1491) ==25829== by 0xA83D60: do_cli (php_cli.c:954) ==25829== by 0xA84F7B: main (php_cli.c:1356) ...
And with ZEND_DONT_UNLOAD_MODULES exported, it shows instead:
# export ZEND_DONT_UNLOAD_MODULES=1 # valgrind --leak-check=full --show-reachable=yes php -r 'echo "Hello World\n";' ... ==25824== 8 bytes in 1 blocks are still reachable in loss record 2 of 30 ==25824== at 0x4C25E84: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==25824== by 0xCE440DC: event_base_priority_init (in /usr/lib/libevent-1.4.so.2.1.3) ==25824== by 0xCE44316: event_base_new (in /usr/lib/libevent-1.4.so.2.1.3) ==25824== by 0xCE44368: event_init (in /usr/lib/libevent-1.4.so.2.1.3) ==25824== by 0xCBEE55F: zm_activate_http_request_pool (http_request_pool_api.c:58) ==25824== by 0xCBD3F87: zm_activate_http (http.c:373) ==25824== by 0x949A85: zend_activate_modules (zend_API.c:2285) ==25824== by 0x8B5EBC: php_request_startup (main.c:1491) ==25824== by 0xA83D60: do_cli (php_cli.c:954) ==25824== by 0xA84F7B: main (php_cli.c:1356) ...
As you can see all the symbols are now nicely resolved. This patch is part of the upcoming PHP 5.4, but applies to PHP 5.2 and PHP 5.3 as well.
Life Line
Created 3 crossings and a waste_basket; Updated a bus_stop and a waste_basket; Deleted a waste_basket
Created an entrance and a staircase entrance
I walked 7.5km in 1h25m21s
Success (well, 80%) with my first real soldering-required project!
I have a board with components that can power three (different) Neopixel shapes in a (prototype) Lego enclosure.
Need to make lots of nice 8x8 pixel art and fonts now though, and get a properly designed Lego box.
The only problem is a wonky connector for my third Neopixel — I'll have to resolder that.
I also have software so that I can change everything through Wi-Fi.
I walked 8.0km in 1h32m34s
Mark roads and tracks as private, as I found out yesterday and got stuck behind a locked fence with a security guard
Updated a bird_hide
Updated a bench
This is not an accessible site. Needs more updates too
This is not an accessible site. Needs more updates too
Created 2 gates
I hiked 18.6km in 4h24m32s
I walked 6.2km in 59m46s
This is indeed no more a clothes shop, but a restaurant
I walked 5.2km in 1h8m43s
Created 2 waste_baskets, 2 boards, and 2 benches; Updated 8 benches, 6 waste_baskets, and 2 other objects; Deleted 2 waste_baskets and a bench
I walked 5.9km in 1h25m05s
I walked 1.1km in 10m15s
Updated a pub
I walked 9.6km in 1h37m31s
Merge branch 'v2022'
Merge branch 'php_gh_19803' into v2022
Fix PHP GH-19803: Parsing a string with a single white space does cre…
Merge branch 'xdebug_3_5'
Back to -dev


Shortlink
This article has a short URL available: https://drck.me/vlgrnd-shared-8qh