The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Case 4471] changing include_path in PHP causes random memory errors

Discussion in 'General Discussion' started by WhiteDog, Dec 15, 2009.

  1. WhiteDog

    WhiteDog Well-Known Member

    Joined:
    Feb 19, 2008
    Messages:
    118
    Likes Received:
    0
    Trophy Points:
    16
    I have a problem changing the include_path from within a php script, either thru ini_set() or set_include_path().

    To reproduce you can use this code:
    PHP:
    echo "getting: ".get_include_path()."\n";
    echo 
    "setting: ".set_include_path("/NEWPATH")."\n";
    echo 
    "getting: ".get_include_path();
    which does work correctly but also throws me this at random:

    PHP:
    Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 295599376 bytesin Unknown on line 0 
    I've already done some digging and the problem appears to be realted to running php in CGI mode:
    - CGI + suExec on = errors
    - CGI + suexec off = OK
    - DSO + suexec on = OK

    I'm running PHP 5.2.9.

    I only found 1 person with the similar problem:
    Memory Exhausted and Core files generated - $5 Script Archive Community Forum

    Any help on debugging this?
     
  2. WhiteDog

    WhiteDog Well-Known Member

    Joined:
    Feb 19, 2008
    Messages:
    118
    Likes Received:
    0
    Trophy Points:
    16
    I have further identified the problem.

    In php.ini
    extension = "homeloader.so"

    if homeloader is active, i get memory errors.
    If i remove that line, no more memory errors but then offcourse things like PEAR don't longer work.

    Can someone please give me some background info on homeloader, how it is supposed to work and how to "officially" enable or disable it with EasyApache / WHM ?
     
  3. jack01

    jack01 Well-Known Member

    Joined:
    Jul 21, 2004
    Messages:
    200
    Likes Received:
    0
    Trophy Points:
    16
    I am also interested in an answer to this post...

    PHP Version 5.2.12
    System Linux [hostname] 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:32:21 EST 2010 x86_64
    Server API CGI (suPHP)

    This program makes use of the Zend Scripting Language Engine:
    Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with the ionCube PHP Loader v3.3.10, Copyright (c) 2002-2009, by ionCube Ltd., and
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
    with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH

    Additional Modules
    Module Name:
    homeloader
    ionCube Loader
     
  4. eXite

    eXite Well-Known Member

    Joined:
    May 16, 2003
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    DataCenter Provider
    We also ran into this problem, when a customer complained about memory leaks and fatal errors when trying to modify the include_path. No matter what PHP function is called (e.g. ini_set('include_path') / set_include_path), the include_path is being corrupted and PHP goes into a loop (resulting in memory exhaustion errors) or throws a memory dump at the user.

    At first I suspected suPHP/FCGI of messing things up. Then I figured out that homeloader.so modifies the include_path, allowing for individual (user specific) PEAR packages to be included from the user's homedir. Apparently, homeloader.so chokes up PHP when the script itself also tries to modify the include_path.

    Disabling homeloader.so was the only solution to our problem. Is this module cPanel specific? Could this be a bug that is in need of some fixing?
     
  5. hostmedic

    hostmedic Well-Known Member

    Joined:
    Apr 30, 2003
    Messages:
    559
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Washington Court House, Ohio, United States
    cPanel Access Level:
    DataCenter Provider
    Not to drag up an old thread - but we are also experiencing this issue.

    http://cpdebug.wecbuilder.org/cpanel-error1.png

    http://cpdebug.wecbuilder.org/cpanel-error2.png

    http://cpdebug.wecbuilder.org/cpanel-fine-after-error.png

    This happens really quickly - and it is hard to catch - but sure enough - errors there as well -
    So I am very confident this is outside of any php application we are running on the server.


    http://cpdebug.wecbuilder.org/test_breaks.php (run that about 20 times and get failures about 35%)

    http://cpdebug.wecbuilder.org/test_works.php
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Have you tested if homeloader.so being commented out results in this not happening on the machine in question? It would be this line in /usr/local/lib/php.ini specifically:

    Code:
    extension=homeloader.so
    Try commenting out the line and restarting Apache to see the results:

    Code:
    ;extension=homeloader.so
    If the above does work to allow cPanel > PHP Extensions and Applications Package Installer area to load without errors, please open up a ticket. Since homeloader.so is needed to use PEAR specific modules for the user's home directory, it would be necessary to have that enabled for those modules to work.
     
  7. hostmedic

    hostmedic Well-Known Member

    Joined:
    Apr 30, 2003
    Messages:
    559
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Washington Court House, Ohio, United States
    cPanel Access Level:
    DataCenter Provider
    We have had an ongoing ticket: ticketid=1324389

    In here - we placed 2 test scripts - very simple

    The first does not work about 50% of the time.

    The second does all the time
    commented this out
    Code:
    //set_include_path(get_include_path(). PATH_SEPARATOR . $path);

    http://cpdebug.wecbuilder.org/test_breaks.php

    Code:
    <?php
    
    echo "This script dies about 50% of the time due to the set_include_path() call.<br />";
    echo "Memory Usage at Start: " . memory_get_usage() / 1024 / 1024 . "<br />";
    
    $path = '.';
    set_include_path(get_include_path(). PATH_SEPARATOR . $path);
    
    $myArray = array();
    while ($i < 1000000) {
    	$myArray[$i] = "Looping...";
    	$test = 'Looping...';
    	$i++;
    }
    
    
    
    echo "Memory Usage at End: " . memory_get_usage() / 1024 / 1024 . "<br />";
    die("Done! (with a die command. any errors after this are after script execution)");
    
    ?>
    
    http://cpdebug.wecbuilder.org/test_works.php
    Code:
    <?php
    
    echo "This script works consistently because set_include_path is commented out.<br/>";
    echo "Memory Usage at Start: " . memory_get_usage() / 1024 / 1024 . "<br />";
    
    $path = '.';
    // set_include_path(get_include_path(). PATH_SEPARATOR . $path);
    
    $myArray = array();
    while ($i < 1000000) {
            $myArray[$i] = "Looping...";
            $test = 'Looping...';
            $i++;
    }
    
    
    
    echo "Memory Usage at End: " . memory_get_usage() / 1024 / 1024 . "<br />";
    die("Done! (with a die command. any errors after this are after script execution)");
    
    ?>
    
    We do have other sites which require PEAR - so disabling it on the system could cause issues - I will let you guys work this from the ticket as well.

    Also - when commented out - sure enough I am able to reach the page ...
     
  8. jack01

    jack01 Well-Known Member

    Joined:
    Jul 21, 2004
    Messages:
    200
    Likes Received:
    0
    Trophy Points:
    16
    To avoid opening a ticket, can anyone update me on the outcome of their tickets about this issue? Is the homeloader.so being fixed in a coming cpanel update or what? Is there a workaround to this until then?

    Many thanks for any help.
     
  9. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    We have an internal bug case (4471) opened about the issue, which is currently being reviewed due to this cropping up for FCGI and CGI installations. Can you please indicate which PHP handler you are on using on your machine?

    At this time, FCGI or CGI + homeloader.so appears to cause errors and will not function. Please note that the homeloader.so module for PHP is used by the "Magic User Loader" module, which is set in WHM > Software Module Installers PHP Extensions and Applications area. It would be enabled by selecting the "Magic User Loader" option. The purpose of the module would be so that users do not have to enter in the full include path for PEAR modules, but PEAR modules will still work without using this module.
     
  10. jack01

    jack01 Well-Known Member

    Joined:
    Jul 21, 2004
    Messages:
    200
    Likes Received:
    0
    Trophy Points:
    16
    Hi cPanelTristan,

    Thanks for the prompt response :)

    Yes our servers in question have PHP running as suPHP (ie. CGI) so they are affected.

    The problem with disabling the homeloader.so ("Magic User Loader") is that by now many clients have coded pages based on the utility of "Magic User Loader" and it will cause upheaval problems to simply disable it.

    I will keep an eye on the bug tracking, thanks.
     
  11. jack01

    jack01 Well-Known Member

    Joined:
    Jul 21, 2004
    Messages:
    200
    Likes Received:
    0
    Trophy Points:
    16
    Oh I didn't realize bugzilla.cpanel.net was no longer directly accessible .... so maybe I won't be keeping an eye on the bug tracking after all (?)
     
  12. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    We use an internal system now for the bug reports, but you can always ask for an update at any point on the forum or via a ticket. Additionally, we use the case numbers for our changelogs for all versions at this point, so you can see whenever a bug has been fixed using Change Logs and looking for your version. There would also be an option to subscribe to the RSS feeds there.

    To see the versions for each tier, the location would be at Downloads - cPanel Inc.

    You can grab your server version using this command:

    Code:
    /usr/local/cpanel/version
     
  13. jack01

    jack01 Well-Known Member

    Joined:
    Jul 21, 2004
    Messages:
    200
    Likes Received:
    0
    Trophy Points:
    16
    The issue with homeloader.so still seems to be in effect; please can you update us on this?
     
  14. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    If you are experiencing this issue, please submit a ticket via:

    Submit A Ticket

    This allows us to reproduce the issue on your system, and then tag the internal case with your ticket number if it's determined to be related to the reported bug.

    Thank you.
     
  15. WhiteDog

    WhiteDog Well-Known Member

    Joined:
    Feb 19, 2008
    Messages:
    118
    Likes Received:
    0
    Trophy Points:
    16
    Amazingly, I encountered this issue again today (after submitting it 3 years ago) :)

    The problem this time was because the user had a custom php.ini in it's root directory (as intended).
    Only difference with normal php.ini in this case is register_globals = 0 in stead of 1.

    When i commented out homeloader.so the problem disappeared...

    Could there be an issue between either:
    - homeloader with a php.ini in a completely different location.
    - homeloader and register_globals

    Perhaps this helps others facing the same problem.
     
  16. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If you would like to add to any bug report for information, please submit a ticket to us. That is the only way to see if that information is useful for the existing case. You can go to http://go.cpanel.net/bugs or the link at the top for reporting information on a bug report. Thanks!
     
Loading...

Share This Page