Mobile app version of vmapp.org
Login or Join
YK1175434

: Track down segmentation faults in PHP? I'm looking for a relatively painless way to track down segmentation faults in PHP (as reported in the Apache error log). This is my LAMP setup at the

@YK1175434

Posted in: #Apache #Lamp #Php

I'm looking for a relatively painless way to track down segmentation faults in PHP (as reported in the Apache error log). This is my LAMP setup at the moment:

Linux: OpenSUSE 11.3 x86_64
Apache: 2.2.15-3.7
MySQL: 5.1.46-2.18
PHP: 5.3.2-1.31

The code in question is not my own, it is Gallery2: gallery.menalto.com A typical scenario is that I go to the gallery main page and none of the thumbnails appear but I get a new set of segmentation fault errors in the error log.

Given the relative complexity of that software, it's not particularly suited to simple forms of debugging. I'd like to be able to step through the code and see exactly what is happening. "Solutions" I've seen so far for doing this have been pretty far from "relatively painless."

I've successfully used Gallery2 on this server (earlier versions of LAMP software packages) and on other servers, so I assume there is something defective in my current configuration, but without being able to see where the fault is occurring, I can't fix or work around it.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @YK1175434

2 Comments

Sorted by latest first Latest Oldest Best

 

@Reiling115

To debug PHP segfaults you'll normally make a new .php file (so that it does not interfere with your main code) like so (calling it my_first_debugger.php):

<?php
include('annoying_caller_page_that_crashes.php');
?>


Then run gdb php. If gdb is not installed or the gdb/php binaries are not in your path there will be errors so use YaST2 to install everything required (get the development/debug libraries for php too as they usually include debugging symbols).

You'll get output like:

GNU gdb x.x
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
(gdb)


Then just do a run my_first_debugger.php in the command line.

Look for -dev and -dbg packages if there are messages like (no debugging symbols found) or you may not see the name of the function being called.

10% popularity Vote Up Vote Down


 

@Speyer207

May I suggest looking at sourceforge.net/tracker/index.php?func=detail&aid=1692166&group_id=7130&atid=107130 and gallery.menalto.com/node/62436#comment-228570?
There seem to be common problems with either using apache_setenv or gzipping the URL twice (depending on the scenario - the former seems more likely with the thumbnails not appearing):


I believe that the problem is that mod_deflate tries to gzip the data a
second time based on the URL, which results in breakages on some systems.
Telling it not to gzip the files that we're sending helps out in this
case.





There may be a bug in PHP. Try adding $gallery->setConfig('apacheSetenvBroken', 1); to your config.php to disable using the apache_setenv() function


Appreciate this is not the answer to the question you are asking (beyond using Zend Framework with plugins or command line php and gdb I do not know how to debug segfaults in PHP) but it may help.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme