Search code examples
phplaravelgoogle-cloud-run

Cloud Run Uncaught signal: 11 after upgrade Laravel 9


I upgraded my project to Laravel 9 with PHP8. But since I deployed on Cloud Run I randomly have this errors in the Cloud Run logs :

Uncaught signal: 11, pid=17, tid=17, fault_addr=4294967296017.

So the query is aborded with 503 error : GET 503 898 octets 682 msChrome 109 https://...

Here is my php-custom.ini :

max_execution_time = 500
upload_max_filesize = 40M
post_max_size = 40M
memory_limit = 800M
max_file_uploads = 100

And my opcache.ini :

[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.max_accelerated_files=32531
opcache.memory_consumption=256
opcache.max_wasted_percentage=10
opcache.interned_strings_buffer=64
opcache.fast_shutdown=1
opcache.jit_buffer_size=100M
opcache.jit=1235

And my dockerfile :

FROM php:8.2.3-apache as base

# Arguments defined in docker-compose.yml
ARG user
ARG uid

WORKDIR /app

# Install PHP dependencies
RUN apt-get update && apt-get install -y \
        libpng-dev \
        zlib1g-dev \
        libxml2-dev \
        libzip-dev \
        libonig-dev \
        zip \
        unzip \
        locales \
        pdftk \
    && sed -i -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen \
    && locale-gen \
    && docker-php-ext-configure gd \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-install mysqli \
    && docker-php-ext-install zip \
    && docker-php-source delete \
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl \
    && docker-php-ext-install opcache \
    && docker-php-ext-install bcmath

# Env
ENV LC_ALL fr_FR.UTF-8 
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR:en

# Copy project, vhost.conf, config php and install composer
COPY . .
COPY docker/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY docker/custom.ini $PHP_INI_DIR/conf.d/custom.ini
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf

# Add permissions
RUN mkdir -p /app/vendor \
    mkdir -p /app/storage/logs \
    && useradd -G www-data,root -u $uid -d /home/$user $user \
    && mkdir -p /home/$user/.composer \
    && chown -R $user:$user /home/$user \
    && chown -R $user:$user /app \
    && a2enmod rewrite \
    && chmod +x docker/startup-dev.sh \
    && chmod +x docker/startup-prod.sh

EXPOSE 8080

FROM base as development
RUN apt-get update && apt-get install -y nano
ENTRYPOINT ["docker/startup-dev.sh"]
CMD ["apache2-foreground"]
USER $user

FROM base as production
COPY docker/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini
RUN composer clearcache && composer install --optimize-autoloader --no-dev
ENTRYPOINT ["docker/startup-prod.sh"]
CMD ["apache2-foreground"]
USER $user

I don't know how to reproduce the bug because it's very random, but I noticed the error appears after the Cloud Run cold start. I don't know if the problem is caused by my opcache config. My Cloud run service has 1 CPU and 2 GO memory.

I don't know how to fix that.

Edit

I'm adding 2 graphs when I got the error :

2023-03-14 error

2023-03-17 error


Solution

  • I solved my problem. That is not about Cloud Run. The problem is the JIT configuration. I changed this:

    opcache.jit=1235 
    

    to

    opcache.jit=1255
    

    According to this : https://php.watch/versions/8.0/JIT#jit-opcache-jit-values I tried both too :

    tracing: An alias to the granular configuration 1254.
    function: An alias to the granular configuration 1205.
    

    And it works too if you don't want to use 1255. But I used 1255 because on this Pull Request I seen lot of Unit Tests with 1255 configuration.