Skip to content

opcache: symbol not found in flat namespace (_zend_gdb_register_code) when JIT enabled on Mac OS X #9639

Closed

Description

@dunglas

Description

When compiling PHP 8.2 on Mac OS X with the following configuration:

./configure --enable-embed=static --enable-zts --with-iconv=/opt/homebrew/opt/libiconv/ --enable-opcache

I get this error when loading the opcache.so extension:

Failed loading /usr/local/lib/php/extensions/no-debug-zts-20220829/opcache.so: dlopen(/usr/local/lib/php/extensions/no-debug-zts-20220829/opcache.so, 0x0009): symbol not found in flat namespace (_zend_gdb_register_code)

Disabling opcache JIT fixes the issue:

./configure --enable-embed=static --enable-zts --with-iconv=/opt/homebrew/opt/libiconv/ --enable-opcache --disable-opcache-jit

PHP Version

PHP 8.2-dev

Operating System

macOS 12.6

Activity

  1. devnexen commented on Sep 29, 2022

    @devnexen
    Member

    I could not reproduce on native arm64 nor in rosetta mode with both gcc and clang, would it be possible to give a bit more context ? did you try for example instead of removing opcache jit, removing zts ?

  2. iluuu1994 commented on Sep 29, 2022

    @iluuu1994
    Member

    This is odd, zend_gdb_register_code is not static and zend_gdb.c is compiled unconditionally.

  3. devnexen commented on Sep 29, 2022

    @devnexen
    Member

    start to wonder if this is a somewhat similar issue found here (as embed sapi involved).

  4. dunglas commented on Sep 29, 2022

    @dunglas
    MemberAuthor

    did you try for example instead of removing opcache jit, removing zts ?

    Good catch, removing --enable-zts fixes the issue too!

    I've written a SAPI to embed PHP in a Go binary. I can provide you a (private) repo with a reproducer if needed!

  5. devnexen commented on Sep 30, 2022

    @devnexen
    Member

    sure why not feel free to send an email if you prefer.

  6. dunglas commented on Sep 30, 2022

    @dunglas
    MemberAuthor

    I upgraded to the latest commit of the PHP-8.2 branch, recompiled with the exact same flags... and the issue is gone.

    Thanks for your help everybody!

  7. dunglas commented on Oct 3, 2022

    @dunglas
    MemberAuthor

    This issue is back again (macOS only). I probably made a mistake while recompiling hiding the issue. I can still give access to a reproducer.

  8. devnexen commented on Oct 3, 2022

    @devnexen
    Member

    did you acknowledge what was advised here ?

  9. dunglas commented on Oct 4, 2022

    @dunglas
    MemberAuthor

    @devnexen this looks related but I'm not sure if that's precisely the same issue. Unlike #9635, I'm not loading PHP as a plugin for another app. PHP is statically compiled in the main Go binary:

    +-------+-------+
    |Go App         |
    +---------------+
    |     PHP       |
    +--+---------+--+
       |         |dlopen/dlsym
    +--+---+ +---+--+
    | PHP  | | PHP  |
    | ext1 | | ext2 |
    +------+ +------+
    

    Basically, the main app loads directly opcache.so.

  10. reopened this on Oct 5, 2022
  11. devnexen commented on Oct 5, 2022

    @devnexen
    Member

    This issue is back again (macOS only). I probably made a mistake while recompiling hiding the issue. I can still give access to a reproducer.

    you can send an email however won t be able to have a proper look at it before this weekend at earliest, pretty busy atm. but if someone else wants a crack at it before me that s fine :-)

  12. dunglas commented on Oct 17, 2022

    @dunglas
    MemberAuthor

    Now that FrankenPHP is public, here is a quick reproducer (on Mac):

    compile PHP

    ./buildconf
    ./configure \
        --enable-embed=static \
        --enable-zts \
        --enable-static \
        --enable-shared=no \
        --with-iconv=/opt/homebrew/opt/libiconv/ \
        --enable-debug
    make -j$(nproc)
    sudo make install
    

    Be sure that opcache is loaded in php.ini

    run Franken's test suite

    # Go must be installed
    git clone --recursive git@github.com:dunglas/frankenphp.git
    cd frankenphp
    go test -v
    

    Result:

    <b>Warning</b>:  Failed loading Zend extension 'opcache' (tried: /usr/local/lib/php/extensions/debug-zts-20220830/opcache (dlopen(/usr/local/lib/php/extensions/debug-zts-20220830/opcache, 0x0009): tried: '/usr/local/lib/php/extensions/debug-zts-20220830/opcache' (no such file)), /usr/local/lib/php/extensions/debug-zts-20220830/opcache.so (dlopen(/usr/local/lib/php/extensions/debug-zts-20220830/opcache.so, 0x0009): symbol not found in flat namespace (_zend_gdb_register_code))) in <b>Unknown</b> on line <b>0</b><br />
    
  13. kamil-tekiela commented on Nov 5, 2026

    @kamil-tekiela
    Member

    I believe this has been "fixed" in PHP 8.4 due to the new JIT IR implementation. Since older PHP versions are unsupported I am closing this. If that is not the case and the issue is still reproducible with the new JIT then please reopen the issue or create a new one with steps to reproduce it against PHP 8.4 or master. Also, opcache is no longer optional so no loading is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions