sail: Segmentation fault with last docker version

Sail Version

1.26

Laravel Version

10.10

PHP Version

8.2

Operating System

Linux

OS Version

Debian 12 (kernel 6.1.0-13-amd64)

Description

With the latest version of docker and docker-desktop, when running ./vendor/bin/sail up, the mysql image is pulled successfully, but when Laravel is building, it crashes (segfault) at Processing triggers for php8.2-cli (8.2.13-1+ubuntu22.04.1+deb.sury.org+1).

I tried purging docker from my computer (along with docker-desktop) but nothing worked.

Maybe as the previous Issue #639 it comes from the docker compose version because I use the version Docker Compose version v2.23.0-desktop.1.

Here is the ouput of the command:

...
71.99 Setting up build-essential (12.9ubuntu3) ...
72.00 Setting up debhelper (13.6ubuntu1) ...
72.01 Setting up pkg-php-tools (1.42build1) ...
72.02 Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
72.05 Processing triggers for fontconfig (2.13.1-4.2ubuntu5) ...
72.18 Processing triggers for php8.2-cli (8.2.13-1+ubuntu22.04.1+deb.sury.org+1) ...
72.23 Segmentation fault
72.58 curl: (23) Failure writing output to destination
------
failed to solve: process "/bin/sh -c apt-get update     && mkdir -p /etc/apt/keyrings     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch     && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null     && echo \"deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main\" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php8.2-cli php8.2-dev        php8.2-pgsql php8.2-sqlite3 php8.2-gd php8.2-imagick        php8.2-curl        php8.2-imap php8.2-mysql php8.2-mbstring        php8.2-xml php8.2-zip php8.2-bcmath php8.2-soap        php8.2-intl php8.2-readline        php8.2-ldap        php8.2-msgpack php8.2-igbinary php8.2-redis php8.2-swoole        php8.2-memcached php8.2-pcov php8.2-xdebug     && curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer     && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg     && echo \"deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main\" > /etc/apt/sources.list.d/nodesource.list     && apt-get update     && apt-get install -y nodejs     && npm install -g npm     && npm install -g pnpm     && npm install -g bun     && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null     && echo \"deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main\" > /etc/apt/sources.list.d/yarn.list     && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null     && echo \"deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main\" > /etc/apt/sources.list.d/pgdg.list     && apt-get update     && apt-get install -y yarn     && apt-get install -y mysql-client     && apt-get install -y postgresql-client-$POSTGRES_VERSION     && apt-get -y autoremove     && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*" did not complete successfully: exit code: 139

Steps To Reproduce

  1. Have the latest docker, docker-composer, and docker-desktop version.
  2. Create a new Laravel project
  3. Install Sail
  4. Run ./vendor/bin/sail up

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 10
  • Comments: 62 (8 by maintainers)

Most upvoted comments

Commenting out the php8.2-xdebug gets the build working.

File: docker/8.2/Dockerfile

Perhaps the compiling of php8.2-xdebug is making the container run out of memory (throwing ideas out there)?

   php8.2-memcached php8.2-pcov php8.2-xdebug \

becomes

   php8.2-memcached php8.2-pcov \ 

Commenting out php8.2-xdebug works for me. Thanks @cjj25 !

Steps to apply the fix with Swoole prior to 5.1.1 installed along with xdebug 3.3

On a new Laravel project

  1. Create the project with composer
  2. Install Sail
  3. Update the file vendor/laravel/sail/runtimes/8.2/Dockerfile with the fix
  4. Run php artisan sail:install

On an already existing project

If you just pulled the project and did not create a docker image, go from step 3 of the first example. Otherwise (already have a docker image setup)

  1. Run php artisan sail:publish
  2. Update the file docker/8.2/Dockerfile with the fix
  3. Run sail build --no-cache

Hope it works for you !

@driesvints I believe the issue is actually with the php8.2-swoole package being outdated.

php -r 'echo swoole_version();' returns 5.1.0

The fix appears to be in 5.1.1 so the package php8.2-swoole on https://ppa.launchpadcontent.net needs be updated.

@GoByeBye thoughts?

You’re right on! Mentioned it above here https://github.com/laravel/sail/issues/641#issuecomment-1836054617. An issue has already been reported https://github.com/oerdnj/deb.sury.org/issues/2058. Now we wait ^^

Heya, thank you all for investigating. We’re not going to be rewriting to Pecl. So I guess the only other option is to wait for a fix from swoole? Did I get that right?

Correct ^^

Does anyone want me to create a ticket on the xdebug official bug tracking pagee ?

Already a report on there https://bugs.xdebug.org/view.php?id=2221

A segmentation fault during an npm command sounds like a very different issue, and unlikely caused by sail. Best to post on a support forum with more full logs of the errors.

(For what its worth, the commands listed worked fine for me, doing ./vendor/bin/sail up -d -- build to make sure to use latest image)

It now builds the docker images again for me. Maybe somebody else can also try it too?

php artisan sail:build --no-cache --pull

@ToguyC Unfortunately you’ll need to modify the actual Dockerfile you originally found in the vendor directly as you can’t run the sail:publish without having a working built docker image.

Oh nice didn’t see it, thanks.

@cjj25 my apologies for being misleading there. It was a fix I rushed out to the devs @ the company I work for before lunch

It seems like it’s the official package that’s broken yeah…

New question for you @cjj25 have you tried specifying the pecl version to an older known good one? We have a container image that’s got xdebug installed but it’s running an old version for stability reasons (3.2.2)

So

RUN apt-get update \
    && mkdir -p /etc/apt/keyrings \
    && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch \
    && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \
    && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
    && apt-get update \
    && apt-get install -y php8.2-cli php8.2-dev \
       php8.2-pgsql php8.2-sqlite3 php8.2-gd php8.2-imagick \
       php8.2-curl \
       php8.2-imap php8.2-mysql php8.2-mbstring \
       php8.2-xml php8.2-zip php8.2-bcmath php8.2-soap \
       php8.2-intl php8.2-readline \
       php8.2-ldap \
       php8.2-msgpack php8.2-igbinary php8.2-redis php8.2-swoole \
       php8.2-memcached php8.2-pcov \
       # XDEBUG fix
    && pecl install xdebug-3.2.2

We also need to specify a xdebug.ini file

zend_extension=REPLACE_WITH_XDEBUG_PATH
xdebug.remote_enable=1
; Disable this and comment in the below code if you need to debug something from another device/ip, such
; as via the online mode, connecting from a phone. Rebuild the docker image and enjoy!
xdebug.discover_client_host=true

;xdebug.idekey="gobyebye-ide-key"
;xdebug.client_host="172.17.0.1"

; If the device does not have support for bookmarklets, or you just want the debugger to always connect (even
; without the XDEBUG_SESSION cookie), change this to yes. Will also start profiling.
xdebug.start_with_request=trigger

xdebug.client_port=9000
xdebug.file_link_format=xdebug://%f@%l

xdebug.output_dir=/xdebug
xdebug.profiler_output_name="cachegrind.out.%s.%u"
xdebug.trace_output_name="trace.%u.%R"
xdebug.trace_format=1

xdebug.var_display_max_depth = 10
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024

xdebug.mode=develop,trace,debug,profile

;https://xdebug.org/docs/all_settings#log_level
xdebug.log_level=3;

; Show all local variablas in error situations.
;xdebug.show_local_vars=true

; break upon error.
;xdebug.start_upon_error=yes

then copy it in

COPY xdebug.ini /etc/php-conf/99-xdebug
RUN sed -i "s#REPLACE_WITH_XDEBUG_PATH#$(ls /usr/lib/php/*/xdebug.so)#" /etc/php-conf/99-xdebug.ini

Hope this helps ^^

Commenting out the php8.2-xdebug gets the build working.

File: docker/8.2/Dockerfile

Perhaps the compiling of php8.2-xdebug is making the container run out of memory (throwing ideas out there)?

   php8.2-memcached php8.2-pcov php8.2-xdebug \

becomes

   php8.2-memcached php8.2-pcov \ 

Nice thanks @Theprim0. I tried several things to mitigate this issue, but setting up the image to use PHP 8.3 seems currently the only working option, although it launched like 2-3 days ago as a stable release.

I tried setting up the sail image to sail-8.3/app and context to 8.3 also, and it seems to work. It can be a workaround but if any project have to use specifically PHP 8.2 it will not be possible.

@driesvints I can confirm, that the issue exists with PHP 8.1 and 8.2 (not tested with PHP 8.0)

PHP 8.3 seems to work fine.

The issue stems from this line of code

https://github.com/laravel/sail/blob/688a820f10fe67ad6dec724721b732d96de9a572/runtimes/8.2/Dockerfile#L31

curl fails when it’s passing piping it out to PHP

Same with 8.1 here !