magento-cloud-docker icon indicating copy to clipboard operation
magento-cloud-docker copied to clipboard

Php Segmentation fault with xdebug

Open spdivn opened this issue 1 year ago • 4 comments
trafficstars

Preconditions

  1. Magento version 2.4.7 - No sample data
  2. PHP 8.3 (magento/magento-cloud-docker-php:8.3-cli-1.3.7)
  3. MySQL 10.6 (mariadb:10.6)
  4. Varnish 6.6 (magento/magento-cloud-docker-varnish:6.6-1.3.7)
  5. Nginx 1.24 (magento/magento-cloud-docker-nginx:1.24-1.3.7)
  6. Opensearch 2.4 (magento/magento-cloud-docker-opensearch:2.4-1.3.7)
  7. Fpm (magento/magento-cloud-docker-php:8.3-fpm-1.3.7)
  8. Redis 7.2 (redis:7.2)

Steps to reproduce

Use this docker-compose that are generated by ece-docker

# ./vendor/bin/ece-docker 'build:compose' --with-cron --with-xdebug --db='10.6' --php='8.3' --mode=developer --host='magento2.local' --no-es
version: '2.1'
services:
  db:
    hostname: db.magento2.local
    image: 'mariadb:10.6'
    shm_size: 2gb
    environment:
      - MYSQL_ROOT_PASSWORD=magento2
      - MYSQL_DATABASE=magento2
      - MYSQL_USER=magento2
      - MYSQL_PASSWORD=magento2
    ports:
      - '3306:3306'
    volumes:
      - '.:/app:delegated'
      - 'mymagento-magento-db:/var/lib/mysql'
    healthcheck:
      test: 'mysqladmin ping -h localhost -pmagento2'
      interval: 30s
      timeout: 30s
      retries: 3
    networks:
      magento:
        aliases:
          - db.magento2.local
  redis:
    hostname: redis.magento2.local
    image: 'redis:7.2'
    volumes:
      - '.:/app:delegated'
    ports:
      - '6379:6379'
    sysctls:
      net.core.somaxconn: 1024
    ulimits:
      nproc: 65535
      nofile:
        soft: 20000
        hard: 40000
    healthcheck:
      test: 'redis-cli ping || exit 1'
      interval: 30s
      timeout: 30s
      retries: 3
    networks:
      magento:
        aliases:
          - redis.magento2.local
  opensearch:
    hostname: opensearch.magento2.local
    image: 'magento/magento-cloud-docker-opensearch:2.4-1.3.7'
    ulimits:
      memlock:
        soft: -1
        hard: -1
    environment:
      - cluster.name=docker-cluster
      - discovery.type=single-node
      - discovery.seed_hosts=opensearch
      - bootstrap.memory_lock=true
      - DISABLE_SECURITY_PLUGIN=true
    networks:
      magento:
        aliases:
          - opensearch.magento2.local
  fpm:
    hostname: fpm.magento2.local
    image: 'magento/magento-cloud-docker-php:8.3-fpm-1.3.7'
    extends: generic
    volumes:
      - '.:/app:delegated'
    networks:
      magento:
        aliases:
          - fpm.magento2.local
    depends_on:
      db:
        condition: service_healthy
  web:
    hostname: web.magento2.local
    image: 'magento/magento-cloud-docker-nginx:1.24-1.3.7'
    extends: generic
    volumes:
      - '.:/app:delegated'
    environment:
      - WITH_XDEBUG=1
      - NGINX_WORKER_PROCESSES=1
      - NGINX_WORKER_CONNECTIONS=1024
    networks:
      magento:
        aliases:
          - web.magento2.local
    depends_on:
      fpm:
        condition: service_started
  varnish:
    hostname: varnish.magento2.local
    image: 'magento/magento-cloud-docker-varnish:6.6-1.3.7'
    networks:
      magento:
        aliases:
          - varnish.magento2.local
    depends_on:
      web:
        condition: service_started
  tls:
    hostname: tls.magento2.local
    image: 'magento/magento-cloud-docker-nginx:1.24-1.3.7'
    extends: generic
    networks:
      magento:
        aliases:
          - magento2.local
    environment:
      - NGINX_WORKER_PROCESSES=1
      - NGINX_WORKER_CONNECTIONS=1024
      - UPSTREAM_HOST=varnish
      - UPSTREAM_PORT=80
    ports:
      - '80:80'
      - '443:443'
    depends_on:
      varnish:
        condition: service_started
  fpm_xdebug:
    hostname: fpm_xdebug.magento2.local
    image: 'magento/magento-cloud-docker-php:8.3-fpm-1.3.7'
    extends: generic
    volumes:
      - '.:/app:delegated'
    environment:
      - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl sodium xdebug'
    networks:
      magento:
        aliases:
          - fpm_xdebug.magento2.local
    depends_on:
      db:
        condition: service_started
  generic:
    hostname: generic.magento2.local
    image: 'magento/magento-cloud-docker-php:8.3-cli-1.3.7'
    env_file: ./.docker/config.env
    environment:
      - MAGENTO_RUN_MODE=developer
      - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl sodium'
      - 'SENDMAIL_PATH=/usr/local/bin/mhsendmail --smtp-addr=mailhog:1025'
  build:
    hostname: build.magento2.local
    image: 'magento/magento-cloud-docker-php:8.3-cli-1.3.7'
    extends: generic
    volumes:
      - '.:/app:delegated'
    networks:
      magento:
        aliases:
          - build.magento2.local
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
      opensearch:
        condition: service_healthy
  deploy:
    hostname: deploy.magento2.local
    image: 'magento/magento-cloud-docker-php:8.3-cli-1.3.7'
    extends: generic
    volumes:
      - '.:/app:delegated'
    networks:
      magento:
        aliases:
          - deploy.magento2.local
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
      opensearch:
        condition: service_healthy
  mailhog:
    hostname: mailhog.magento2.local
    image: 'magento/magento-cloud-docker-mailhog:1.0-1.3.7'
    ports:
      - '1025:1025'
      - '8025:8025'
    networks:
      magento:
        aliases:
          - mailhog.magento2.local
  cron:
    hostname: cron.magento2.local
    image: 'magento/magento-cloud-docker-php:8.3-cli-1.3.7'
    extends: generic
    command: run-cron
    environment:
      CRONTAB: '* * * * * root cd /app && /usr/local/bin/php bin/magento cron:run >> /app/var/log/cron.log'
    volumes:
      - '.:/app:delegated'
    networks:
      magento:
        aliases:
          - cron.magento2.local
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
      opensearch:
        condition: service_healthy
volumes:
  mymagento-magento-db: {  }
networks:
  magento:
    driver: bridge
  1. Install local docker-compose up -d
  2. Enter on fpm_xdebug container
  3. Exec php -i

Expected result

  1. Show all php information image

Actual result

  1. Segmentation fault (core dumped) image

spdivn avatar Aug 22 '24 08:08 spdivn

I can reproduce it.

vacla avatar Aug 27 '24 08:08 vacla

I believe I am experiencing this same issue, though specifically what I'm seeing is that when I set the appropriate debug cookies / headers in a browser at attempt to debug I'm seeing 502 errors in the browser and SIGSEGV in the fpm_xdebug container:

Screenshot 2024-09-17 at 1 22 39 PM

kevin-mitchell avatar Sep 17 '24 04:09 kevin-mitchell

I believe this is the same issue as https://github.com/magento/magento-cloud-docker/issues/366

willryan-stemcell avatar Nov 20 '24 00:11 willryan-stemcell

I can reproduce it with version 1.4.0 of images.

mfauvell avatar Feb 06 '25 11:02 mfauvell

I can confirm this issue also occurs with the following images:

  • magento/magento-cloud-docker-php:8.4-cli-1.4.2
  • magento/magento-cloud-docker-php:8.3-cli-1.4.2
  • magento/magento-cloud-docker-php:8.3-cli-1.4.1

The segfault is reproducible with php -i as soon as Xdebug is loaded.

jeromecx avatar May 06 '25 15:05 jeromecx

I can confirm this is the issue is fully reproducible as described by @jeromecx

xpoback avatar Jul 15 '25 11:07 xpoback

We ran into this and found Blackfire library was causing the segfault.

lmatysikpartsasap avatar Aug 27 '25 15:08 lmatysikpartsasap

The cause of the problem in the incompatibility of Blackfire with Xdebug, as they themselves mention.

If Blackfire is not used, it can be disabled. This worked for me (magento/magento-cloud-docker-php:8.3-cli-1.4.3):

# inside the container
# find the configuration file
find / -type f -name "*blackfire.ini"

# remove the configuration fiel (this one in my case)
rm -f /usr/local/etc/php/conf.d/zz-blackfire.ini

And then it started working fine.

Thanks @lmatysikpartsasap for the hint!

I'd expect @magento/magento-cloud-docker-team to take a look at this and maybe add some documentation for resolving this problem.

xpoback avatar Oct 15 '25 10:10 xpoback