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

Function registration failed - duplicate name #1

Closed
jedisct1 opened this issue Nov 11, 2013 · 30 comments
Closed

Function registration failed - duplicate name #1

jedisct1 opened this issue Nov 11, 2013 · 30 comments
Assignees
Labels

Comments

@jedisct1
Copy link
Contributor

The extension doesn't seem to load on OSX / PHP 5.4.17:

PHP Warning:  Function registration failed - duplicate name - sodium\nonce::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\nonce::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\public_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\public_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\public_key::__get in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\public_key::__isset in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\public_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\public_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__get in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__isset in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::load in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__get in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__isset in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\secret_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__get in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__isset in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::load in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__get in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__isset in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::load in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__destruct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__get in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__isset in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__construct in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - sodium\precomp_key::__destruct in Unknown on line 0

Do you happen to know what can be causing this?

@aletheia7
Copy link
Owner

No. Perhaps there are two "extension = sodium.so" lines being included in the php.ini? grep all of the php.ini files for the sodium.so extension.

Are you using php namespaces? If so, use \sodium\precomp_key instead of sodium\precomp_key.

@aletheia7
Copy link
Owner

Perhaps you are compiling php-sodium extension statically in your php build and also loading the shared library. Take a look here [http://bytes.com/topic/php/answers/468411-php-command-line-issues-function-registration-failed-duplicate-name]

@jedisct1
Copy link
Contributor Author

Hello,

I only added extension=sodium.so to /etc/php.ini. I'm using xdebug the same way without any issues.
This is the PHP version that ships with OSX 10.9. Not something I compiled.
And the error shows up before php has a chance to start parsing the file.

Weird. Never saw that before.

@aletheia7
Copy link
Owner

Do you get the error when you run php -m, php -i ?

@aletheia7
Copy link
Owner

extension = sodium.so is correct.

@jedisct1
Copy link
Contributor Author

Yep, same error with php -m and php -i.

@aletheia7
Copy link
Owner

Try commenting-out all extensions except php-sodium and run php -i . The error message indicates the extension is being loaded more than once. Is the extension loaded in apache?

@jedisct1
Copy link
Contributor Author

I'm starting it from the command line.
No dynamic extension is loaded except sodium.so

php -i: https://gist.github.com/jedisct1/7425567

@aletheia7
Copy link
Owner

I reviewed the php -i output. It looks good. Try commenting-out the php-sodium extension and run php -i . Does the [sodium] block still indicate being loaded? Also, set:

display_errors = on
display_startup_errors = on
log_errors = on
error_reporting = E_ALL | E_STRICT
; either syslog | /path/to/a/file
error_log = syslog

and run php -i.

Are any php processes running? Can you kill them?

@ghost ghost assigned aletheia7 Nov 12, 2013
@aletheia7
Copy link
Owner

Strange error. Can you upgrade/downgrade php easily to try a different version? Are all of the Mac OSX patches installed for php?

@aletheia7
Copy link
Owner

Check your apache error logs too.

@jedisct1
Copy link
Contributor Author

php is run in command line mode, not via Apache.

I'm going to compile it from source and see if it makes a difference, but still... other extensions don't have this issue with the stock OSX PHP.

What PHP version did you test with?

@aletheia7
Copy link
Owner

PHP 5.3.10-1ubuntu3.8 with Suhosin-Patch (cli) (built: Sep 4 2013 20:05:42)

@aletheia7
Copy link
Owner

I just compiled php-sodium on debian wheezy/stable against php 5.5.5:

PHP 5.5.5-1 (cli) (built: Oct 19 2013 22:09:48)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

I did not have a problem.

sodium

sodium support => enabled
sodium extension version => 1.0.3
sodium library version => 0.4.5
randombytes implementation name => sysrandom
endian => little endian

@jedisct1
Copy link
Contributor Author

I compiled 5.5.5 on OSX from source (using Homebrew, so a very common setup), and on another machine.

Same issue. Even "make test", without changing anything to php.ini, spits out these errors.

PHP         : /usr/local/Cellar/php55/5.5.5/bin/php
Warning: Function registration failed - duplicate name - sodium\nonce::__construct in Unknown on line 0

Warning: Function registration failed - duplicate name - sodium\nonce::__destruct in Unknown on line 0

Warning: Function registration failed - duplicate name - sodium\public_key::__construct in Unknown on line 0

Warning: Function registration failed - duplicate name - sodium\public_key::__destruct in Unknown on line 0

Warning: Function registration failed - duplicate name - sodium\public_key::__get in Unknown on line 0

Warning: Function registration failed - duplicate name - sodium\public_key::__isset in Unknown on line 0

and so on...

@aletheia7
Copy link
Owner

Checkout this: [https://github.com/midgardproject/midgard-php5/issues/113]

@jedisct1
Copy link
Contributor Author

Sounds very similar indeed.

@jedisct1
Copy link
Contributor Author

Did you find what the issue was?

@aletheia7
Copy link
Owner

The php-sodium extension is being loaded more than once. The homebrew/php environment is loading the extension. The error points to the php compilation/linking environment.

I did not get an answer to "Try commenting-out the php-sodium extension and run php -i . Does the [sodium] block still indicate being loaded?"

@jedisct1
Copy link
Contributor Author

Nope, if I don't include the extension=sodium.so line (tried with the full path as well), php -i / phpinfo() doesn't mention it.

@jedisct1
Copy link
Contributor Author

And I have the same issue both with the php version that comes with OSX, and with php 5.5.5 installed by Homebrew.

@aletheia7 aletheia7 reopened this Nov 14, 2013
@aletheia7
Copy link
Owner

OK. FYI. Works fine on Windows Server 2003, Ubuntu, and two 5.3/5.5 on Debian. I wish I had an OSX machine to debug the build process. The error seems to point to php being compiled with a php-sodium extension statically linked along with a extension=sodium.so in the php.ini. It is a strange error. Could you check your command PATH. Perhaps the build process is using one version of php and the cli is another? Do you have more than one version of php installed?

@jedisct1
Copy link
Contributor Author

I had no problems making it work on a Debian machine either. So, there must be something specific to OSX.
And unfortunately, not having an OSX machine to reproduce makes this pretty tricky to fix.

When I initially reported this issue, I only had one PHP version, installed by default with OSX. This is on a new machine, with a fresh OSX 10.9 install. I now have the Homebrew version in addition to it, but it seems to pick up the correct phpize script.

Out of desperation, I wrote a simple PHP extension and it seems to work fine on OSX. But the code is very basic and doesn't use namespaces, nor define classes.
Do not close this issue. I'm going to try to incrementally removing things in your extension until I can pinpoint the specific thing that breaks on OSX.

@aletheia7
Copy link
Owner

Sounds good. The PHP_MINIT_FUNCTION macro becomes a function that registers the classes. If this were called twice, then the duplicate names might be a result. Is the configure process including the php-sodium sodium.c twice? I doubt it would compile.

@aletheia7
Copy link
Owner

If you save the C code after the compiler macro expansion, we could search for the zend_register function to see if it is called twice.

@aletheia7
Copy link
Owner

I uploaded a branch entitled null_test. Give it a try. I was missing some "nulls" in some structures.

@aletheia7
Copy link
Owner

Tag 1.0.4 and master branch now contain null_test.

@aletheia7
Copy link
Owner

Removed null_test branch. Try version 1.0.4.

@jedisct1
Copy link
Contributor Author

Good news! Version 1.0.4 fixes it!

@aletheia7
Copy link
Owner

Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants