Skip to content

PHP 8.3.30 - CLI Segmentation Fault Signal 11 when script finishes (core dumped) #21600

Closed

Description

@Munktells

Description

The following code:

<?php
#!/usr/bin/env php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

if (PHP_SAPI !== 'cli') {
    echo 'bin/magento must be run as a CLI application';
    exit(1);
}

try {
    require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
    echo 'Autoload error: ' . $e->getMessage();
    exit(1);
}
try {
    $handler = new \Magento\Framework\App\ErrorHandler();
    set_error_handler([$handler, 'handler']);
    $application = new Magento\Framework\Console\Cli('Magento CLI');
    $application->run();
} catch (\Throwable $e) {
    while ($e) {
        if ($e->getFile()) {
            echo sprintf("\nThere is an error in %s", $e->getFile());
            if ($e->getLine()) {
                echo sprintf(" at line: %d", $e->getLine());
            }
            echo "\n";
        }
        echo $e->getMessage();
        echo $e->getTraceAsString();
        echo "\n\n";
        $e = $e->getPrevious();
    }
    exit(Magento\Framework\Console\Cli::RETURN_FAILURE);
}
?>

Resulted in this output:

Flushed cache types:
config
layout
block_html
collections
reflection
db_ddl
compiled_config
eav
customer_notification
config_integration
config_integration_api
graphql_query_resolver_result
full_page
config_webservice
translate
Segmentation fault <------------ NOTE ------------<<<

But I expected this output instead:
No segfault when done running the script.
Note that the script finishes successfully - problem shutting down in right order?

GDB

Reading symbols from /usr/local/bin/php...
(No debugging symbols found in /usr/local/bin/php)
[New LWP 100537]
Core was generated by `php: /usr/local/bin/php /usr/local/www/webroot/bin/magento c'.
Program terminated with signal SIGSEGV, Segmentation fault.
Address not mapped to object.
#0  0x000000082759a8fd in ?? () from /lib/libc.so.7
(gdb) bt
#0  0x000000082759a8fd in ?? () from /lib/libc.so.7
#1  0x000000082759196d in ?? () from /lib/libc.so.7
#2  0x0000000825e24cd8 in xmlHashFree () from /usr/local/lib/libxml2.so.16
#3  0x000000085d1eae0e in xsltCleanupGlobals () from /usr/local/lib/libxslt.so.1
#4  0x000000085bac5549 in zm_shutdown_xsl () from /usr/local/lib/php/20230831/xsl.so
#5  0x00000000005ddeda in ?? ()
#6  0x00000000005eac45 in zend_hash_graceful_reverse_destroy ()
#7  0x00000000005d2b18 in ?? ()
#8  0x00000000005619d9 in php_module_shutdown ()
#9  0x00000000006c18fa in ?? ()
#10 0x000000082749f37f in __libc_start1 () from /lib/libc.so.7
#11 0x00000000003f08c4 in _start ()
(gdb)

PHP Version

PHP 8.3.30 (cli) (built: Mar 31 2026 19:06:24) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.30, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.30, Copyright (c), by Zend Technologies

Operating System

FreeBSD 15

Activity

  1. devnexen commented on Apr 2, 2026

    @devnexen
    Member

    Hi @Munktells what are the dependencies versions ? i.e. pkg info libxml2 libxslt

  2. Munktells commented on Apr 2, 2026

    @Munktells
    Author

    Hi @Munktells what are the dependencies versions ? i.e. pkg info libxml2 libxslt

    The current versions in the system is:

    # pkg info libxml2 libxslt
    libxml2-2.15.2
    libxslt-1.1.45
    
  3. devnexen commented on Apr 2, 2026

    @devnexen
    Member

    I may have a look later but do you have the possibility to quickly test with a newer php version ?

  4. Munktells commented on Apr 2, 2026

    @Munktells
    Author

    I may have a look later but do you have the possibility to quickly test with a newer php version ?

    No not at the moment I'm afraid, that could break other functions, not yet compatible with PHP 8.4/8.5.
    I need to stay on PHP 8.3 for a short while more.

  5. devnexen commented on Apr 2, 2026

    @devnexen
    Member

    Ok fair enough, not sure if this is misuage of libxslt api here ; wrong extension shutdown sequence to which it might have been fixed already in upper branches ... we ll see !

  6. self-assigned this
    on Apr 2, 2026
  7. Munktells commented on Apr 2, 2026

    @Munktells
    Author

    Ok fair enough, not sure if this is misuage of libxslt api here ; wrong extension shutdown sequence to which it might have been fixed already in upper branches ... we ll see !

    More people seem to have similar problems, even in 8.4 and 8.5, someone pointed this to me:
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291622

  8. nwellnhof commented on Apr 2, 2026

    @nwellnhof

    Here's another FreeBSD bug report with two different stack traces: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277888

    One of them doesn't involve the xsl module, so the issue might be unrelated to libxslt.

    # lldb -o r -- php -r 'proc_open(["date"], [], $pipes);'
    (lldb) target create "php"
    Current executable set to 'php' (x86_64).
    (lldb) settings set -- target.run-args  "-r" "proc_open([\"date\"], [], $pipes);"
    (lldb) r
    Wed May 29 15:13:58 CEST 2024
    Process 35995 stopped
    * thread #1, name = 'php', stop reason = signal SIGSEGV: invalid address (fault address: 0x888e9c408)
        frame #0: 0x00000000005c5e21 php`zend_function_dtor + 49
    php`zend_function_dtor:
    ->  0x5c5e21 <+49>: testb  $0x40, 0x4(%rdi)
        0x5c5e25 <+53>: jne    0x5c5e30                  ; <+64>
        0x5c5e27 <+55>: addl   $-0x1, (%rdi)
        0x5c5e2a <+58>: je     0x5c5ec4                  ; <+212>
    Process 35995 launched: '/usr/local/bin/php' (x86_64)
    (lldb) bt
    * thread #1, name = 'php', stop reason = signal SIGSEGV: invalid address (fault address: 0x888e9c408)
      * frame #0: 0x00000000005c5e21 php`zend_function_dtor + 49
        frame #1: 0x00000000005ea4a7 php`zend_hash_destroy + 119
        frame #2: 0x00000000005c6a9a php`destroy_zend_class + 1146
        frame #3: 0x00000000005eb395 php`zend_hash_graceful_reverse_destroy + 517
        frame #4: 0x00000000005d2e3a php`___lldb_unnamed_symbol6918 + 58
        frame #5: 0x0000000000564b29 php`php_module_shutdown + 41
        frame #6: 0x00000000006c4516 php`___lldb_unnamed_symbol8658 + 822
        frame #7: 0x00000000003f22d0 php`_start + 256
    (lldb) q
    Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] 
    
  9. Munktells commented on Apr 2, 2026

    @Munktells
    Author

    I may have a look later but do you have the possibility to quickly test with a newer php version ?

    I might need to move over to 8.4.x sooner than later, just saw that 8.3.x only gets security updates from now on.
    Let me get back if this PR goes away with 8.4.x.

  10. added a commit that references this issue on Apr 2, 2026
    7fec72c
  11. Munktells commented on Apr 4, 2026

    @Munktells
    Author

    The issue is still present when upgrading to PHP 8.4.19, on FreeBSD 15.0-RELEASE-p5 (and others?).

    But the commit fixes the issue, no more segfaults and signal 11 when script finishes.

  12. added 2 commits that reference this issue on Apr 4, 2026
    96e93e9
    ea7a136
  13. added a commit that references this issue on Apr 4, 2026
    d7c3b3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions