libsodium-php icon indicating copy to clipboard operation
libsodium-php copied to clipboard

`sodium_crypto_pwhash_str` end up with `Uncaught SodiumException: internal error`

Open lbajsarowicz opened this issue 3 years ago • 6 comments

print_r(explode('$', sodium_crypto_pwhash_str('string',SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE)));

Ends up with:

Fatal error: Uncaught SodiumException: internal error in /in/4adjf:3
Stack trace:
#0 /in/4adjf(3): sodium_crypto_pwhash_str()
#1 {main}
  thrown in /in/4adjf on line 3

Process exited with code 255.

Since PHP 8.1.2 on some platforms.

https://3v4l.org/4adjf

lbajsarowicz avatar Jul 03 '22 23:07 lbajsarowicz

What does phpinfo() say about libsodium library & extension versions?

jedisct1 avatar Jul 05 '22 09:07 jedisct1

We use exactly the same Docker image on all the environments:

Configure Command =>  './configure'  '--build=aarch64-linux-gnu' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--with-pic' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-password-argon2' '--with-sodium=shared' '--with-pdo-sqlite=/usr' '--with-sqlite3=/usr' '--with-curl' '--with-iconv' '--with-openssl' '--with-readline' '--with-zlib' '--enable-phpdbg' '--enable-phpdbg-readline' '--with-pear' '--with-libdir=lib/aarch64-linux-gnu' '--enable-embed' 'build_alias=aarch64-linux-gnu'
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
sodium
sodium support => enabled
libsodium headers version => 1.0.18
libsodium library version => 1.0.18

lbajsarowicz avatar Jul 05 '22 09:07 lbajsarowicz

Not enough memory, maybe? What happens if you set the memory limit to something small?

jedisct1 avatar Jul 05 '22 09:07 jedisct1

With 256M of memory, the same result: https://3v4l.org/AHABm Also, in the CI environment, we have 2G of memory limit for CLI (you know, Magento)

image

lbajsarowicz avatar Jul 05 '22 09:07 lbajsarowicz

Do you know of a way to reproduce this? I tried the PHP package from Homebrew and couldn't duplicate this.

jedisct1 avatar Jul 05 '22 14:07 jedisct1

@jedisct1 I was able to reproduce that with 3v4l and with Gitlab CI environments. Can't reproduce that with the same Docker image on a local environment (Macbook M1)

lbajsarowicz avatar Jul 05 '22 15:07 lbajsarowicz