Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionCube(?) causes bin/magento to segfault when run inside the debug container (PHP 8.1) #35

Open
mattijv opened this issue Aug 30, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@mattijv
Copy link

mattijv commented Aug 30, 2024

Tested with

  • Warden 0.14.3
  • PHP 8.1.29 (seems to be the current default when initializing Warden environment)
  • Xdebug 3.3.2
  • ionCube Loader 13.3.1

Steps to reproduce

  1. Initialize a new Warden environment warden env-init, choose magento2 as the type.
  2. Install symfony/console with composer require symfony/console.
  3. Add the test file (below) and enter the debug container.
  4. Run php test.php.

This should result in the following:

www-data@segfault-php-debug:/var/www/html$ php test.php 
Segmentation fault (core dumped)

(Xdebug will complain about not being able to connect, but that does not affect the problem so I omitted it from the output.)

Test file to trigger the issue

<?php

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\CompleteCommand;

require 'vendor/autoload.php';

$attribute = (new \ReflectionClass(CompleteCommand::class))->getAttributes(AsCommand::class);

$attribute[0]->newInstance();

Details

I faced this problem when running the Magento CLI command (bin/magento) and tracked down the problematic lines to \Symfony\Component\Console\Command\Command::getDefaultName (when subclassed as \Symfony\Component\Console\Command\CompleteCommand). The test file is a minimal sample that triggers the issue.

Running the file with gdb reveals the following stack trace after triggering the segfault:

Program received signal SIGSEGV, Segmentation fault.
0x000055f832a87323 in zend_observer_fcall_end ()
(gdb) bt full
#0  0x000055f832a87323 in zend_observer_fcall_end ()
#1  0x000055f832a55519 in execute_ex ()
#2  0x00007fdb459e83f5 in ?? () from /usr/lib64/php/modules/ioncube_loader.so
#3  0x00007fdb459e847b in ?? () from /usr/lib64/php/modules/ioncube_loader.so
#4  0x00007fdb45a8ef0d in ?? () from /usr/lib64/php/modules/ioncube_loader.so
#5  0x00007fdb45a9af70 in ?? () from /usr/lib64/php/modules/ioncube_loader.so
#6  0x00007fdb459a61b3 in ?? () from /usr/lib64/php/modules/ioncube_loader.so
#7  0x00007fdb4592c995 in xdebug_execute_internal () from /usr/lib64/php/modules/xdebug.so
#8  0x000055f832832df4 in ZEND_DO_FCALL_SPEC_OBSERVER_HANDLER ()
#9  0x000055f83283382a in execute_ex[cold] ()
#10 0x00007fdb459e83f5 in ?? () from /usr/lib64/php/modules/ioncube_loader.so
#11 0x00007fdb459e847b in ?? () from /usr/lib64/php/modules/ioncube_loader.so
#12 0x000055f832a5f1d9 in zend_execute ()
#13 0x000055f8329ef250 in zend_execute_scripts ()
#14 0x000055f832989f1a in php_execute_script ()
#15 0x000055f832ad83fe in do_cli ()
#16 0x000055f83283ddeb in main ()

The segmentation fault does not happen if I either

  1. run the sample program from the normal (non-Xdebug) shell, OR
  2. disable the ionCube loaders by commenting out the line in /etc/php.d/01-ioncube-loader.ini.

Thoughts

I'm guessing this is an issue with ionCube and not in the Warden images per se. However, since the images bundle the problematic version, and I can't quickly find an official way to disable it, I'm opening this issue here.

@mattijv
Copy link
Author

mattijv commented Aug 30, 2024

It appears this does not happen with PHP 8.2 or 8.3.

@mattijv mattijv changed the title ionCube(?) causes bin/magento to segfault when run inside the debug container ionCube(?) causes bin/magento to segfault when run inside the debug container (PHP 8.1) Aug 30, 2024
@navarr navarr added the bug Something isn't working label Sep 6, 2024
@navarr navarr added this to Warden Sep 6, 2024
@navarr navarr moved this to 🆕 New in Warden Sep 6, 2024
@CSalih
Copy link

CSalih commented Sep 19, 2024

Same issue also with PHP 8.2 and 8.3. Disabling ionCube solves the issue.

PHP 8.2.23 (cli) (built: Aug 27 2024 15:32:20) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.23, Copyright (c) Zend Technologies
    with the ionCube PHP Loader v13.3.1, Copyright (c) 2002-2024, by ionCube Ltd.
    with Zend OPcache v8.2.23, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
PHP 8.3.11 (cli) (built: Aug 27 2024 19:16:34) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with the ionCube PHP Loader v13.3.1, Copyright (c) 2002-2024, by ionCube Ltd.
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

@navarr
Copy link
Member

navarr commented Sep 19, 2024

@mattijv @CSalih What is your OS and Architecture (x64/aarch64)?

Interestingly, I'm not seeing this on Mac OS X 14.5 aarch64.

www-data@magento-multisite-php-debug:/var/www/html$ php test.php

Warning: Undefined array key 0 in /var/www/html/test.php on line 10

Fatal error: Uncaught Error: Call to a member function newInstance() on null in /var/www/html/test.php:10
Stack trace:
#0 {main}
  thrown in /var/www/html/test.php on line 10
PHP 8.1.29 (cli) (built: Jun  5 2024 05:51:57) (NTS gcc aarch64)
Copyright (c) The PHP Group
Zend Engine v4.1.29, Copyright (c) Zend Technologies
    with the ionCube PHP Loader v13.3.1, Copyright (c) 2002-2024, by ionCube Ltd.
    with Zend OPcache v8.1.29, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

@CSalih
Copy link

CSalih commented Sep 19, 2024

@navarr Ubuntu 24 and MacOS 15 both running on x64 architecture. Seems to be an x64 related issue?

@mattijv
Copy link
Author

mattijv commented Sep 19, 2024

x86_64
Ubuntu 24.04.1 LTS

@CSalih
Copy link

CSalih commented Sep 19, 2024

@mattijv do you have the latest image? You may run warden env pull && warden env up and it try again?

Edit: For PHP 8.2 and 8.3

@mattijv
Copy link
Author

mattijv commented Sep 19, 2024

Changed the PHP version in .env to 8.2 and 8.3, and did warden env pull between each test.

www-data@segfault-php-debug:/var/www/html$ php --version
PHP 8.2.23 (cli) (built: Aug 27 2024 15:32:20) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.23, Copyright (c) Zend Technologies
    with the ionCube PHP Loader v13.3.1, Copyright (c) 2002-2024, by ionCube Ltd.
    with Zend OPcache v8.2.23, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
www-data@segfault-php-debug:/var/www/html$ php test.php 
[snip xdebug warning]
www-data@segfault-php-debug:/var/www/html$ 
www-data@segfault-php-debug:/var/www/html$ php --version
PHP 8.3.11 (cli) (built: Aug 27 2024 19:16:34) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with the ionCube PHP Loader v13.3.1, Copyright (c) 2002-2024, by ionCube Ltd.
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
www-data@segfault-php-debug:/var/www/html$ php test.php 
[snip xdebug warning]
www-data@segfault-php-debug:/var/www/html$ 

No errors (beside the xdebug warnings).

Went back to 8.1:

www-data@segfault-php-debug:/var/www/html$ php --version
PHP 8.1.29 (cli) (built: Jun  5 2024 05:51:57) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.29, Copyright (c) Zend Technologies
    with the ionCube PHP Loader v13.3.1, Copyright (c) 2002-2024, by ionCube Ltd.
    with Zend OPcache v8.1.29, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
www-data@segfault-php-debug:/var/www/html$ php test.php 
[snip xdebug warning]
Segmentation fault (core dumped)
www-data@segfault-php-debug:/var/www/html$ 

@prince-prc
Copy link

prince-prc commented Nov 29, 2024

I also have the same problem Segmentation fault => warden debug

Versions:
Warden 0.15.0
Php 8.1.30
IonCube 14.0.0
Zend 4.1.30
Magento 2.4.6

Ubuntu 24.04.1 LTS
Kernel 6.8.0-49-generic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🆕 New
Development

No branches or pull requests

4 participants