News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Derick Rethans:
Understanding Valgrind errors (1)
February 04, 2014 @ 11:03:02

Using the Valgrind tool can give you a good window into the inner workings of your PHP script (at a very low level) but the results it gives can be a bit confusing to interpret. In his latest post Derick Rethans uses the memcheck tool that comes as a part of Valgrind to monitor memory usage and interprets some of the results.

Memcheck is really valuable for C and C++ developers and something you should learn, especially when you write PHP extensions. Memcheck's error messages can sometimes be difficult to understand, so with this (infrequent series), I hope to shed some light on it. Let's have a look at the following Valgrind error output, which I encountered while debugging issue PHP-963 of the MongoDB driver for PHP.

He walks though the output and how to spot the actual error - a reference to a null pointer in the C code. He tracks it back through the code and finds the spot where it references the wrong memory segment in the Mongo PHP extension code.

In short, an error where Address 0x38 is not stack'd, malloc'd or (recently) free'd has a low address in the message often means a NULL-pointer dereference.
0 comments voice your opinion now!
valgrind error memcheck mongo extension

Link: http://derickrethans.nl/valgrind-null.html

blog comments powered by Disqus

Similar Posts

php|architect: The CodeWorks 2010 early-bird extended to October 4th (TODAY!)

Douglas Brown's Blog: Quick Methods Used for Solving PHP Errors

DevShed: Handling HTML Strings and Files with the DOM XML Extension in PHP 5

Hasin Hayder: Installing gearmand, libgearman & pecl gearman for php from source in Debian 6 & 7

Hasin Hayder's Blog: Installing PECL subversion extension for PHP in Ubuntu 7.10


Community Events





Don't see your event here?
Let us know!


library deployment symfony release community introduction zendserver api tips language unittest update laravel opinion interview podcast package framework install series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework