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

Volker Dusch's Blog:
Dealing with segfaults while PHPUnit code coverage generation for CI
Apr 14, 2011 @ 11:55:13

Volker Dusch has a new post to his blog looking at handling segfaults during code coverage generation that might come up during your continuous integration process (with PHPUnit flavor unit tests).

About half the "Build failed" mails I’ve gotten from Jenkins in the last two weeks where not due to me breaking the tests but just PHPUnit segfaulting. "Wait! I know PHPUnit can’t segfault!", only PHP itself can. And it does, quite often. For some reason that probably has to do with using PHP 5.2.OLD it doesn’t survive generate the clover.xml file or the HTML report about 20% of the times it’s being run.

He finds a solution to keep this from happening - not correcting the segfault as much as running the testing again to get it to pass. He wraps the call to PHPUnit inside of a simple shell script that tries to execute the PHPUnit testing suite as long as a segfault isn't thrown. If something was seriously broken, this could cause all sorts of problems, but in theory it's a simple hack that gets the job done.

tagged: jenkins phpunit build continuousintegration codecoverage segfault

Link:

Lars Strojny's Blog:
PHP Segfaulting with PECL/UUID and PECL/IMAGICK
Sep 08, 2010 @ 14:17:13

If you've been using (or will be using) the uuid and imagick extensions for PHP, you might be able to save yourself a lot of headache by reading this new post from Lars Strojny about his segfault woes.

Ran into a bug yesterday, where http://pecl.php.net/uuid in combination with http://pecl.php.net/imagick yielded a segfault when using uuid_create().

After trying to trace it down with a backtrace and cachegrind results, he (and Mikko & Pierre) found that both extensions were built against the libuuid.so.1 file. While that wasn't the issue directly, they did find a work-around that helped the issue - renaming some ini files so uuid was loaded first.

tagged: uuid imagick pecl extension segfault debug libuuid

Link:

Matthew Turland's Blog:
A Few Kinks in FilterIterator
Aug 16, 2010 @ 10:18:40

In this quick post to his blog Matthew Turland shares a "kink" he found in using the FilterIteractor SPL iterator when working with the Phergie project's code.

Once I discovered the segfault [from the FilterIterator code], I had to come up with a short code sample exposing the bug in order to report it.

He talks about the bug that led him to the segfault and a second bug that was a side effect of the first causing the first element to be skipped during iteration.

tagged: filteriterator spl bug iterate segfault

Link:

Derick Rethans' Blog:
PHP's segmentation faults GDB-fu
Oct 08, 2008 @ 09:32:09

Derick Rethans has shared a quick tip for locating a code crashing kind of problem with your application when something like XDebug isn't around.

However, because we as PHP developers are lazy, provide a few GDB tricks to make this easier. First of all, it's only really going to work if you haven't stripped the symbols from your PHP and Apache binaries. Secondly, you still need to have the PHP source lying around somewhere.

He suggests using GDB to run the backtraces and create a file to help you track down the infinite recursion problem that could be giving you issues.

tagged: segfault gdb infinite recursion source backtrace

Link:

Paul Jones' Blog:
Exceptional command-line PHP
Aug 08, 2008 @ 09:34:59

In a new post to his blog, Paul Jones anout a small issue when working with the PHP 5.2.5 command line functionality - a segfault if you extend the Exception class.

When executing code at the command line using php -r and PHP 5.2.5, be sure not to extend the Exception class. It will cause a segmentation fault.

He includes examples of the issue that would cause the problem and the bug he's filed in an effort to get it fixed.

tagged: exception commandline php5 extend segfault

Link:

Ian Selby's Blog:
Weird PHP Seg Faults & Custom Session Handlers
Sep 18, 2007 @ 10:27:00

In recent work, Ian Selby came across something odd - a setup where PHP was segfaulting without any real indication of where the error might be:

Starting to get a little frustrated, I took a peek at my error logs (/var/log/httpd/error_log for the unitiated), and discovered a wonderful message [about the segfault]. As any person scratching their head would do, I hit up google.. to no real avail. Just a bunch of php bug reports. So, what happened, and how did I fix it?

After searching through the code and narrowing down where it could be, the culprit looked like a custom session handler he was using. It uses MySQL to store the sesion information and, unfortunately, when Ian had compiled the server he didn't let PHP know about his unique setup.

His default installation was trying to use the default MySQL information (including the socket) to reach the database. Obviously failing, the server simply gave up and segfaulted. Thankfully, all it takes it a recompile with a few extra parameters and you're back in business.

tagged: segfault custom session handler mysql default configure segfault custom session handler mysql default configure

Link:

Ian Selby's Blog:
Weird PHP Seg Faults & Custom Session Handlers
Sep 18, 2007 @ 10:27:00

In recent work, Ian Selby came across something odd - a setup where PHP was segfaulting without any real indication of where the error might be:

Starting to get a little frustrated, I took a peek at my error logs (/var/log/httpd/error_log for the unitiated), and discovered a wonderful message [about the segfault]. As any person scratching their head would do, I hit up google.. to no real avail. Just a bunch of php bug reports. So, what happened, and how did I fix it?

After searching through the code and narrowing down where it could be, the culprit looked like a custom session handler he was using. It uses MySQL to store the sesion information and, unfortunately, when Ian had compiled the server he didn't let PHP know about his unique setup.

His default installation was trying to use the default MySQL information (including the socket) to reach the database. Obviously failing, the server simply gave up and segfaulted. Thankfully, all it takes it a recompile with a few extra parameters and you're back in business.

tagged: segfault custom session handler mysql default configure segfault custom session handler mysql default configure

Link:

Community News:
PHP 4.4.5 Segfaults (register_globals = on)
Feb 23, 2007 @ 09:31:00

According to this new post on DynamicWebPges.de and a message from Derick Rethans on the php.internals mailing list, there's an issue with PHP 4.4.5 where sessions are causing segfaults when register_globals is set to "On".

As per Derick:

Because of this I'd like to release a 4.4.6 soon with this fixes. As there is also an upgrade to pcre 7.0 we'd need at least one RC, which I plan to release on Thursday.

Users of the PHP 4.4.x series should keep watch for this new update to correct the issue quickly.

tagged: segfault registerglobals php4 releasecandidate fix segfault registerglobals php4 releasecandidate fix

Link:

Community News:
PHP 4.4.5 Segfaults (register_globals = on)
Feb 23, 2007 @ 09:31:00

According to this new post on DynamicWebPges.de and a message from Derick Rethans on the php.internals mailing list, there's an issue with PHP 4.4.5 where sessions are causing segfaults when register_globals is set to "On".

As per Derick:

Because of this I'd like to release a 4.4.6 soon with this fixes. As there is also an upgrade to pcre 7.0 we'd need at least one RC, which I plan to release on Thursday.

Users of the PHP 4.4.x series should keep watch for this new update to correct the issue quickly.

tagged: segfault registerglobals php4 releasecandidate fix segfault registerglobals php4 releasecandidate fix

Link:

Stuart Herbert's Blog:
Investigating A PDO Segfault
Jun 29, 2006 @ 05:56:34

Most of the time, working with PDO is simple - fire up the right driver for what you need and you're all set. But sometimes, something's just not right, as Stuart Herbert found out. He's blogged about this experience in his latest entry.

I've been playing about with using PDO to work with mysql. Something's not quite right in there, and it's resulting in a segfault when I run some local unit tests.

PDO objects themselves are created and destroyed when I'd expect them to be, as the objects go out of scope. The problem is that the PDOStatement objects aren't doing the same. According to gdb, PDOStatement objects are only getting cleaned up when php_request_shutdown() runs; never before.

Surely we should be seeing PDOStatement objects being destroyed before their corresponding PDO object?

He finds that there are relly two problems at work here - persistence of PDOStatement objects and PDO objects' destruction before their corresponding PDOStatement objects.

He asks for any opinions on the matter from anyone with the experience out there to help squash these bugs.

tagged: pdo segfault debug pdostatement object pdo pdo segfault debug pdostatement object pdo

Link: