Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED [CPANEL-22645] Shells spawned via cPanel Terminal inherit memory limits from cpsrvd

Discussion in 'General Discussion' started by seb.witt, Oct 21, 2018.

  1. seb.witt

    seb.witt Member

    Joined:
    Oct 21, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Germany
    cPanel Access Level:
    Root Administrator
    Hello, our webhost directed us here since he was out of ideas as well, so let me try to sum up what is happening.
    If you need anything else, please let me know.

    So, the issue arises using composer from within cpanel terminal
    It not happens via whm terminal and using 'su user' to execute the command. But we need to have this available in cpanel

    The command in question, with any package
    Code:
    composer require package/package --profile
    I know this consumes a lot of memory. Once executed we get
    Code:
    [123.2MB/8.52s] Using version ^2.1 for buzz/laravel-google-captcha
    [123.3MB/8.53s] ./composer.json has been updated
    [125.2MB/8.75s] Loading composer repositories with package information
    [125.4MB/9.11s] Updating dependencies (including require-dev)
    mmap() failed: [12] Cannot allocate memory
    mmap() failed: [12] Cannot allocate memory
    Fatal error: Out of memory (allocated 591405056) (tried to allocate 4096 bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer/DependencyResolver/Solver.php on line 220
    
    Looking at the top command while executing this, I see the memory jumps max up to 20%, but the cpu hits 100%, so I guess the process gets killed.

    What we tried
    - Shell fork bomb protection is off. Tried enabling and higher/lower the values, the error stays the same, always killed of at 591405056
    - manually adding the values, same as fork bomb protection
    - Adjusting the pam values in /etc/security/limits.conf. Doesnt's seem to have any effect though
    - Higher the php memory limit, to no effect, setting to -1 with php -d memory_limit=-1 composer.....
    The php cli shouldn't have any limit to begin with if i'm not wrong though
    - Switching between all kind of mpm for apache with different php handlers and modules, all to no avail

    System info
    1) Cpanel 74.0 (build 9)
    2) CENTOS 7.5 virtuozzo
    3) Kernel 2.6.32-042stab125.5
    4) As you see we on openvz vps, with no swap for ram, host doesn't allow switching to vswap
    5) 4gb ram ( 4 processors Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz )
    6) Apache mpm_event with php-fpm and currently for testing purpose without OPcache

    ulimit -a in whm
    Code:
    [/COLOR][/FONT][/LEFT]
    core file size                   (blocks, -c) 0
    data seg size                   (kbytes, -d) unlimited
    scheduling priority           (-e) 0
    file size                           (blocks, -f) unlimited
    pending signals                (-i) 385882
    max locked memory         (kbytes, -l) 64
    max memory size             (kbytes, -m) unlimited
    open files                         (-n) 1024
    pipe size                          (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size                        (kbytes, -s) 10240
    cpu time                          (seconds, -t) unlimited
    max user processes          (-u) 385882
    virtual memory                 (kbytes, -v) unlimited
    file locks                           (-x) unlimited
    

    ulimit -a in cpanel
    Adjusting this via /etc/profile not allows a higher limit than 786432 for memory
    Code:
    core file size                  (blocks, -c) 0
    data seg size                  (kbytes, -d) unlimited
    scheduling priority           (-e) 0
    file size                           (blocks, -f) unlimited
    pending signals                (-i) 385882
    max locked memory         (kbytes, -l) 64
    max memory size             (kbytes, -m) 786432
    open files                         (-n) 1024
    pipe size                          (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority               (-r) 0
    stack size                         (kbytes, -s) 10240
    cpu time                           (seconds, -t) unlimited
    max user processes           (-u) 385882
    virtual memory                 (kbytes, -v) 786432
    file locks                           (-x) unlimited
    [/COLOR][/FONT][/LEFT]
    

    free -m

    Code:
    [LEFT][FONT=Verdana][COLOR=rgb(85, 85, 85)]              total        used        free      shared  buff/cache   available
    Mem:      4096        1167         902         133        2026        2783
    Swap:     0           0           0[/COLOR][/FONT][/LEFT]
    

    ipcs -lm

    Code:
    [LEFT][FONT=Verdana][COLOR=rgb(85, 85, 85)]------ Shared Memory Limits --------
    max number of segments = 4096
    max seg size (kbytes) = 32768
    max total shared memory (kbytes) = 8388608
    min seg size (bytes) = 1[/COLOR][/FONT][/LEFT]
    

    Thank you, seb
     
  2. seb.witt

    seb.witt Member

    Joined:
    Oct 21, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Germany
    cPanel Access Level:
    Root Administrator
    Sorry for some formatting issues, tried to edit, but it doesn't allow me due spam detection.

    Also forgot, php is PHP 7.2.11
     
  3. seb.witt

    seb.witt Member

    Joined:
    Oct 21, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Germany
    cPanel Access Level:
    Root Administrator
    Can someone at least confirm if this an intended feature, or something undocumented?
    This only happens in the cpanel terminal and not your regular ssh client. ( tested on 2 different vps with different setups )
    Also doesn't seem to be affected by the tweak settings Max cPanel process memory (Minimum: 768)
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @seb.witt,

    Internal case CPANEL-22645 was opened to address an issue where cPanel >> Terminal inherit memory limits from cpsrvd. I'll monitor this case and update this thread once the solution is published. In the meantime, the temporary workaround is to access SSH via a third-party client (or the operating system's built-in client). Alternatively, you can temporarily increase the Max cPanel process memory value in WHM >> Tweak Settings.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. seb.witt

    seb.witt Member

    Joined:
    Oct 21, 2018
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Germany
    cPanel Access Level:
    Root Administrator
    Hello, thank you for confirming.

    That was tested as well, as mentioned in my previous post, even setting to unlimited did not work
     
  6. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    cPanel & WHM version 76.0.1 is now published to the EDGE and CURRENT release tiers. Included with this build is a solution to the issue reported on this thread:

    Fixed case CPANEL-22645: Fix memory limits for shells spawned within cPanel.

    The full change log is available here.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice