Uploaded image for project: 'Couchbase PHP client library'
  1. Couchbase PHP client library
  2. PCBC-112

"undefined symbol: php_json_decode in Unknown on line 0" when load couchbase.so library

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Incomplete
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: library
    • Security Level: Public
    • Labels:
      None
    • Environment:

      Description

      Affects Versions:
      1.0.6-1
      1.1.0dp9-1

      Here are steps to reproduce error in version 1.0.6-1, (version 1.1.0dp9-1 is similar):
      1. create file /etc/yum.repos.d/couchbase.repo

      [couchbase]
      name = Couchbase package repository

      1. baseurl = http://packages.couchbase.com/rpm/6.2/x86_64
        baseurl = http://packages.couchbase.com/preview/rpm/5.5/x86_64
        gpgcheck=0

      2. yum install libcouchbase1

      3.

      1. wget http://packages.couchbase.com/clients/php/php-ext-couchbase-1.0.5-centos62-x86_64.tar.gz
      2. tar xzf php-ext-couchbase-1.0.5-centos62-x86_64.tar.gz
      3. cp php-ext-couchbase/couchbase.so /usr/lib64/php/modules/

      4. add the following line to /etc/php.d/json.ini:
      extension=couchbase.so

      5. # service php-fpm restart
      Stopping php-fpm: [ OK ]
      Starting php-fpm: [10-Sep-2012 17:42:45] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/couchbase.so' - /usr/lib64/php/modules/couchbase.so: undefined symbol: php_json_decode in Unknown on line 0
      [ OK ]

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        ingenthr Matt Ingenthron added a comment -

        This is not a bug.

        This is an issue with the order of the extensions, and it's mentioned in the installation section on http://www.couchbase.com/develop/php/current

        Solution is to put the extension in a different .ini file.

        Show
        ingenthr Matt Ingenthron added a comment - This is not a bug. This is an issue with the order of the extensions, and it's mentioned in the installation section on http://www.couchbase.com/develop/php/current Solution is to put the extension in a different .ini file.
        Hide
        thanhbv thanhbv added a comment - - edited

        No. I think this is a new bug.
        Have you read carefully the error description above?

        The installation document say that:
        "The easiest workaround if you encounter this is to edit the ini file that loads the JSON extension (typically /etc/php.d/json.ini) and add the Couchbase extension after the JSON extension."

        Not " put the extension in a different .ini file".

        OK. I will describe more detail:
        1.
        ~2 month ago, in one of my server, running centos 6.2 & php 5.4, couchbase-server 1.8.0, I have install this php extension successfully:
        a. If I add "extension=couchbase.so" in /etc/php.d/couchbase.ini => error.
        b. If I put "extension=couchbase.so" in /etc/php.d/zzcouchbase.ini, OR add "extension=couchbase.so" to the end of /etc/php.d/json.ini => success.

        2. Yesterday, In my other server with centos to 6.3, php-5.4.6-1.el6.remi.x86_64 (newer than the php package in my first server), couchbase-server 1.8.1 => this error (even if I config as in session 1.b above!)

        Then, I think you should try the steps above before closing this issue.
        thank you.

        Show
        thanhbv thanhbv added a comment - - edited No. I think this is a new bug. Have you read carefully the error description above? The installation document say that: "The easiest workaround if you encounter this is to edit the ini file that loads the JSON extension (typically /etc/php.d/json.ini) and add the Couchbase extension after the JSON extension." Not " put the extension in a different .ini file". OK. I will describe more detail: 1. ~2 month ago, in one of my server, running centos 6.2 & php 5.4, couchbase-server 1.8.0, I have install this php extension successfully: a. If I add "extension=couchbase.so" in /etc/php.d/couchbase.ini => error. b. If I put "extension=couchbase.so" in /etc/php.d/zzcouchbase.ini, OR add "extension=couchbase.so" to the end of /etc/php.d/json.ini => success. 2. Yesterday, In my other server with centos to 6.3, php-5.4.6-1.el6.remi.x86_64 (newer than the php package in my first server), couchbase-server 1.8.1 => this error (even if I config as in session 1.b above!) Then, I think you should try the steps above before closing this issue. thank you.
        Hide
        mnunberg Mark Nunberg added a comment - - edited

        The problem would be in your PHP configuration.

        The json function not found is actually compiled into PHP, and should be present (in Debian's 5.4 it's there as part of the binary).

        The extension code compiles out references to php_json_* if it's not defined in PHP's own header files. If you do a simple search for php_json here https://github.com/couchbase/php-ext-couchbase/blob/master/couchbase.c you'll see there isn't a place where php_json_* is mentioned without #define guards ensuring it doesn't work on non-JSONified PHPs.

        I am not familiar with the specific RPM you're using.. let me check that out..

        Show
        mnunberg Mark Nunberg added a comment - - edited The problem would be in your PHP configuration. The json function not found is actually compiled into PHP, and should be present (in Debian's 5.4 it's there as part of the binary). The extension code compiles out references to php_json_* if it's not defined in PHP's own header files. If you do a simple search for php_json here https://github.com/couchbase/php-ext-couchbase/blob/master/couchbase.c you'll see there isn't a place where php_json_* is mentioned without #define guards ensuring it doesn't work on non-JSONified PHPs. I am not familiar with the specific RPM you're using.. let me check that out..
        Hide
        ingenthr Matt Ingenthron added a comment -

        Typically issues with undefined symbols indicate either an order of loading libraries problem or something like using 32-bit binaries on a 64-bit system. In this particular case, you're reporting that it can't load the symbol for php_json_decode. Since we don't ship php_json_decode, it's either missing from your install, you're loading in the wrong order or you're loading the wrong architecture.

        My guess is that you may not have the php_json_decode for some reason. We test this on stock CentOS 6.2 before shipping, and we would have caught a symbol resolution then.

        Do you still have this issue with stock PHP from the standard CentOS 6 repository? If so, we can look into it further.

        Show
        ingenthr Matt Ingenthron added a comment - Typically issues with undefined symbols indicate either an order of loading libraries problem or something like using 32-bit binaries on a 64-bit system. In this particular case, you're reporting that it can't load the symbol for php_json_decode. Since we don't ship php_json_decode, it's either missing from your install, you're loading in the wrong order or you're loading the wrong architecture. My guess is that you may not have the php_json_decode for some reason. We test this on stock CentOS 6.2 before shipping, and we would have caught a symbol resolution then. Do you still have this issue with stock PHP from the standard CentOS 6 repository? If so, we can look into it further.
        Hide
        thanhbv thanhbv added a comment - - edited

        I have just attached file phpinfo.html.

        I use PHP 5.4. The stock PHP from the standard CentOS 6 repository is only 5.3.3

        Now, I must use php-pecl-memcached-2.1.0-2.el6.remi.1.x86_64 as a workaround

        Show
        thanhbv thanhbv added a comment - - edited I have just attached file phpinfo.html. I use PHP 5.4. The stock PHP from the standard CentOS 6 repository is only 5.3.3 Now, I must use php-pecl-memcached-2.1.0-2.el6.remi.1.x86_64 as a workaround
        Hide
        thanhbv thanhbv added a comment -

        If I build from souce then it work as expected:

        $ git clone https://github.com/couchbase/php-ext-couchbase.git
        $ cd php-ext-couchbase

        1. yum --enablerepo=remi,remi-test install php-devel
          $ phpize
          $ ./configure
          $ make
          $ make test
          $ make install
        2. echo 'extension=couchbase.so' > /etc/php.d/zzcouchbase.ini
        3. service php-fpm restart
        Show
        thanhbv thanhbv added a comment - If I build from souce then it work as expected: $ git clone https://github.com/couchbase/php-ext-couchbase.git $ cd php-ext-couchbase yum --enablerepo=remi,remi-test install php-devel $ phpize $ ./configure $ make $ make test $ make install echo 'extension=couchbase.so' > /etc/php.d/zzcouchbase.ini service php-fpm restart
        Hide
        ingenthr Matt Ingenthron added a comment -

        This appears to have been a problem with the specific PHP version in use, and we've not been able to reproduce it with stock PHP. We plan to add testing for 5.4 soon.

        Show
        ingenthr Matt Ingenthron added a comment - This appears to have been a problem with the specific PHP version in use, and we've not been able to reproduce it with stock PHP. We plan to add testing for 5.4 soon.
        Hide
        ingenthr Matt Ingenthron added a comment -

        In the end, this is NOT an issue with php 5.4, but rather an issue with some distributions of PHP not including core functionality. This has been confirmed by the PHP core team.

        To address this, we're adding some documentation (see PCBC-141). Here's a summary from the discussion on the documentation (Thanks to Mark Nunberg).

        ------------
        PHP distributions which have JSON built in, (This includes Debian-based distributions, and Windows binary releases), the only thing required is to have a SINGLE line
        extension=couchbase.so
        For PHP distributions which have JSON as a module (This includes Red Hat EL-based distributions, as noted above), there are two required lines in this very
        extension=json.so
        extension=couchbase.so

        [ As a side note, for Windows users, one might need to substitute 'couchbase.so' with 'couchbase.dll', or 'php_couchbase.dll' (not sure which one) ].

        We will refer to these incantations (for the purpose of this discussion thread) as 'one-line' and 'two-line'

        If one places a one-line incantation where the two-line is required, they will get a cryptic message to the effect of:

        unable to load couchbase.so: cannot find symbol 'php_json_decode'
        (the exact text might be different.. I will try and give an exact quote). At which point the couchbase extension will be unavailable)

        If one places the two-line incantation where a one-line is required, they will receive a harmless warning stating:

        extension 'json' already loaded
        (again, this might not be the exact text)
        --------

        Show
        ingenthr Matt Ingenthron added a comment - In the end, this is NOT an issue with php 5.4, but rather an issue with some distributions of PHP not including core functionality. This has been confirmed by the PHP core team. To address this, we're adding some documentation (see PCBC-141 ). Here's a summary from the discussion on the documentation (Thanks to Mark Nunberg). ------------ PHP distributions which have JSON built in , (This includes Debian-based distributions, and Windows binary releases), the only thing required is to have a SINGLE line extension=couchbase.so For PHP distributions which have JSON as a module (This includes Red Hat EL-based distributions, as noted above), there are two required lines in this very extension=json.so extension=couchbase.so [ As a side note, for Windows users, one might need to substitute 'couchbase.so' with 'couchbase.dll', or 'php_couchbase.dll' (not sure which one) ]. We will refer to these incantations (for the purpose of this discussion thread) as 'one-line' and 'two-line' If one places a one-line incantation where the two-line is required, they will get a cryptic message to the effect of: unable to load couchbase.so: cannot find symbol 'php_json_decode' (the exact text might be different.. I will try and give an exact quote). At which point the couchbase extension will be unavailable) If one places the two-line incantation where a one-line is required, they will receive a harmless warning stating: extension 'json' already loaded (again, this might not be the exact text) --------
        Hide
        perry Perry Krug added a comment -

        So this needs to be reopened right? because it requires us to build a specific a package for RHEL 5.4?

        Show
        perry Perry Krug added a comment - So this needs to be reopened right? because it requires us to build a specific a package for RHEL 5.4?
        Hide
        ingenthr Matt Ingenthron added a comment -

        Correct, needs to be reopened.

        A workaround for now would be to download the PHP 1.0.6 source, build, test and release. Source is available from:
        https://github.com/couchbase/php-ext-couchbase/archive/1.0.6.tar.gz

        The included README covers how to build/test. It does require a php development environment, which is a separate package on RH. Usually I think it's php54-devel, but I'd have to check.

        Show
        ingenthr Matt Ingenthron added a comment - Correct, needs to be reopened. A workaround for now would be to download the PHP 1.0.6 source, build, test and release. Source is available from: https://github.com/couchbase/php-ext-couchbase/archive/1.0.6.tar.gz The included README covers how to build/test. It does require a php development environment, which is a separate package on RH. Usually I think it's php54-devel, but I'd have to check.
        Hide
        ingenthr Matt Ingenthron added a comment -

        Though, I should have said, I think in this original bug, there were multiple issues. I'm going to close this one and open a specific issue for support of PHP 5.4.

        Show
        ingenthr Matt Ingenthron added a comment - Though, I should have said, I think in this original bug, there were multiple issues. I'm going to close this one and open a specific issue for support of PHP 5.4.
        Hide
        ingenthr Matt Ingenthron added a comment -

        See tracking of support of PHP 5.4 in PCBC-151.

        Show
        ingenthr Matt Ingenthron added a comment - See tracking of support of PHP 5.4 in PCBC-151 .
        Hide
        alkavan Igal Alkon added a comment - - edited

        I just had the same issue when install on CentOS 6.3
        the solution thanhbv offered worked although all tested failed !
        i did:
        make install
        mv /etc/php.d/json.ini /etc/php.d/0json.ini

        then phpinfo();
        [root@null ~]# php phpinfo.php | grep couch
        /etc/php.d/couchbase.ini,
        couchbase
        couchbase support => enabled
        couchbase.compression_factor => 1.3 => 1.3
        couchbase.compression_threshold => 2000 => 2000
        couchbase.compressor => none => none
        couchbase.durability_default_poll_interval => 100000 => 100000
        couchbase.durability_default_timeout => 40000000 => 40000000
        couchbase.serializer => php => php
        couchbase.view_timeout => 75 => 75
        OLDPWD => /root/php-ext-couchbase
        _SERVER["OLDPWD"] => /root/php-ext-couchbase

        Using the compiled one from the site did not work.

        Show
        alkavan Igal Alkon added a comment - - edited I just had the same issue when install on CentOS 6.3 the solution thanhbv offered worked although all tested failed ! i did: make install mv /etc/php.d/json.ini /etc/php.d/0json.ini then phpinfo(); [root@null ~] # php phpinfo.php | grep couch /etc/php.d/couchbase.ini, couchbase couchbase support => enabled couchbase.compression_factor => 1.3 => 1.3 couchbase.compression_threshold => 2000 => 2000 couchbase.compressor => none => none couchbase.durability_default_poll_interval => 100000 => 100000 couchbase.durability_default_timeout => 40000000 => 40000000 couchbase.serializer => php => php couchbase.view_timeout => 75 => 75 OLDPWD => /root/php-ext-couchbase _SERVER ["OLDPWD"] => /root/php-ext-couchbase Using the compiled one from the site did not work.

          People

          • Assignee:
            Unassigned
            Reporter:
            thanhbv thanhbv
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes