2

When I type this in shell (Linux):

php index.php

Sometime PHP script terminate and I get an error saying:

Segmentation Fault

Sometime it work fine and sometime I get an error

In the php script it include PDO (mysql), Curl, some loop and "Simple HTML Dom" library

PHP Version:

username [~/www/]# php -v
PHP 5.2.9 (cli) (built: Oct  9 2010 02:01:46)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by ionCube Ltd., and
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technolog

How to fix this problem? I had no problem when I tested on Windows 7 (PHP 5.3.0).

hakre
  • 193,403
  • 52
  • 435
  • 836
user622378
  • 2,318
  • 6
  • 42
  • 63
  • 1
    Its going to be very hard to figure out if the script is not attached. I would try to get a minimal script that can reproduce the problem (with a combination of pdo/curl etc) and post that here. The other option is to do an strace when you run the command (lookup man strace for options).b – rajasaur Jul 06 '11 at 17:13
  • 3
    I would first remove ionCube from the list of extensions and then try again. If it still fails, I would remove the Zend Optimizer as well. Then if it still fails, I think the suggestion from rajasaur is a good way to find out more. Alternatively, [run the script in GDB](http://stackoverflow.com/questions/6343674/phpunit-segmentation-fault/6344061#6344061). – hakre Jul 06 '11 at 17:14

2 Answers2

3

It is about a memory access violation. In your case, this error may be due to (non-exhaustive list):

  1. a stack overflow (often happens when the recursion level for a given function is too high)

  2. too much data to be put in variables (e.g., you try to put the whole content of a huge file in a variable)

To know what causes trouble in your script, try commenting bigger and bigger parts to see which one is at the origin of the bug.

Mathieu Rodic
  • 6,637
  • 2
  • 43
  • 49
0

It seems your problem was solved earlier: PHP Out of Memory - Crashes Apache? May be the problem lies in memory leaks of Simple HTML Dom: http://simplehtmldom.sourceforge.net/manual_faq.htm#memory_leak

Community
  • 1
  • 1