phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.76k stars 1.98k forks source link

[BUG]: Failure to Install with PECL #16476

Open aaugusto-kelmar opened 6 months ago

aaugusto-kelmar commented 6 months ago

Describe the bug When installing via PECL (and also when trying to install with the install script in the build directory), the install gets stuck in a loop spitting out the following error:

/usr/include/php/20210902/Zend/zend_API.h:1984:76: note: expected 'zend_string **' {aka 'struct _zend_string **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 1984 | static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)
      |                                                              ~~~~~~~~~~~~~~^~~~
In file included from /usr/include/php/20210902/Zend/zend_types.h:25,
                 from /usr/include/php/20210902/Zend/zend.h:27,
                 from /usr/include/php/20210902/main/php.h:32,
                 from /tmp/pear/temp/phalcon/phalcon.zep.c:46:
/tmp/pear/temp/phalcon/phalcon.zep.c: In function 'zim_Phalcon_Db_Dialect_Mysql_createTable':
/usr/include/php/20210902/Zend/zend_API.h:1815:58: warning: passing argument 2 of 'zend_parse_arg_str' from incompatible pointer type [-Wincompatible-pointer-types]
 1815 |                 if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null, _i))) { \
/usr/include/php/20210902/Zend/zend_portability.h:338:52: note: in definition of macro 'UNEXPECTED'
  338 | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
      |                                                    ^~~~~~~~~
/usr/include/php/20210902/Zend/zend_API.h:1822:9: note: in expansion of macro 'Z_PARAM_STR_EX'
 1822 |         Z_PARAM_STR_EX(dest, 0, 0)
      |         ^~~~~~~~~~~~~~
/tmp/pear/temp/phalcon/phalcon.zep.c:68603:17: note: in expansion of macro 'Z_PARAM_STR'
68603 |                 Z_PARAM_STR(tableName)
      |                 ^~~~~~~~~~~
In file included from /usr/include/php/20210902/main/php.h:36,
                 from /tmp/pear/temp/phalcon/phalcon.zep.c:46:
/usr/include/php/20210902/Zend/zend_API.h:1984:76: note: expected 'zend_string **' {aka 'struct _zend_string **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 1984 | static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)

To Reproduce

pecl channel-update pecl.php.net
pecl install phalcon

Expected behavior Phalcon installed successfully

Details

Additional context Install was working last week but as of Friday it stopped working and would encounter this error.

s-ohnishi commented 6 months ago

Maybe the machine you're using doesn't have enough specs (especially memory)? I am using Phalcon in a Docker container, and have had the experience of completing compilation by increasing the memory allocated to WSL2 (as a result, increasing the container's memory). This post states that at least 3Gb of memory is required.

kgrammer commented 5 months ago

@niden and I were working on a PHP 8.3 build issue and I confirmed that PECL does not work on a small server. I was trying to install with PECL on a 1CPU/2GB server and PECL was failing. When I upgraded to a 2CPU/4GB server, PECL installed Phalcon as expected.

andypost commented 5 months ago

Confirm that build log is full of warnings like summary notes, building it for Alpinelinux http://build.alpinelinux.org/buildlogs/build-edge-x86_64/testing/php81-pecl-phalcon/php81-pecl-phalcon-5.6.0-r0.log

elcreator commented 3 weeks ago

Try to run (in screen or separate terminal window the next script after starting the build:

#!/bin/bash
while :; do
    cc1_pids=$(pgrep cc1)
    for pid in $cc1_pids; do
        if ! pgrep -P $pid cpulimit; then
            echo "Limiting CPU usage for process $pid"
            sudo cpulimit -p $pid --limit=80 --background
        fi
    done
    sleep 5
done

@niden maybe it's possible to limit the resource usage through config or better via command line parameter?

elcreator commented 3 weeks ago

Also check memory, and if it's less than 4GB (cheapest VDS on Hetzner now has 4GB) and there is no swap (i.e. empty output of sudo swapon --show) probably it's time to add swap file before the build:

sudo fallocate -l 4G /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
s-ohnishi commented 3 weeks ago

The VPS I use has 2GB of memory allocated to it, and according to the results of the free command, 2GB of swap was also assigned. I tried installing it with pecl, and the installation completed without any problems. I haven't tested it thoroughly yet, so I don't know if it works completely. This is because I seem to have seen reports that when installing with pecl in an environment with insufficient memory, "it works for the most part, but some parts don't work." I hope I'm remembering it wrong.

elcreator commented 3 weeks ago

yes, 4GB ram+swap or above should work. In my config it fails with 3,7GB RAM without swap.

s-ohnishi commented 3 weeks ago

Nowadays, VPSs often use SSD storage, so I think it has become easier to use swap than before. If you can specify the swap yourself, it is very convenient to be able to compile even on an inexpensive VPS with little RAM. I also have a VPS with 1GB of RAM allocated to it, so I would like to try to see if I can compile on that VPS someday.

It would be great if you could install the executable file from the Phalcon official website, but unfortunately this is not possible these days. sury.org is available, but it is unfortunate that it is not the latest version.

niden commented 3 weeks ago

The only thing I can offer for memory issues is this post in Stack Overflow

https://stackoverflow.com/questions/22819934/compiling-phalcon-virtual-memory-exhausted-cannot-allocate-memory

The original post was taken down, but I have the archive.org link.

I had a similar issue with bitbucket pipelines compiling Phalcon from source and I ended up compiling it without having the mysql service enabled.

s-ohnishi commented 3 weeks ago

So based on past cases and observations, what is needed is 4GB "including swap", right?

It would be nice if we could get the latest executable file in some repository. This is generally the easiest way.