erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.3k stars 2.94k forks source link

(UndefinedFunctionError) function :crypto.hash/2 is undefined (module :crypto is not available) #8134

Open psumbera opened 7 months ago

psumbera commented 7 months ago

I have working combination of Erlang OTP 24.2 / Elixir 1.12.1 / Hex 1.0.1 / Rabbitmq 3.8.35 .

I'm trying to update just Erlang to version 24.3.4.16 to get some fixes.

When I try to rebuild with it Rabbitmq I get following error:

Unchanged:
  csv 2.4.1
  json 1.4.1
  observer_cli 1.7.3
  parallel_stream 1.0.6
  recon 2.5.2
  stdout_formatter 0.2.4
* Getting json (Hex package)

08:48:52.986 [error] Unable to load crypto library. Failed with error:
":load, Library load-call unsuccessful (226)."

08:48:53.009 [warn]  The on_load function for module crypto returned:
{:error, {:load, 'Library load-call unsuccessful (226).'}}

** (UndefinedFunctionError) function :crypto.hash/2 is undefined (module :crypto is not available)
    (crypto 5.0.6.4) :crypto.hash(:sha256, <<86, 69, 82, 83, 73, 79, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, )
    (hex 1.0.1) src/mix_hex_tarball.erl:153: :mix_hex_tarball.unpack/3
    (hex 1.0.1) lib/hex/tar.ex:36: Hex.Tar.unpack!/2
    (hex 1.0.1) lib/hex/scm.ex:165: Hex.SCM.update/1
    (hex 1.0.1) lib/hex/scm.ex:231: Hex.SCM.checkout/1
    (mix 1.12.1) lib/mix/dep/fetcher.ex:64: Mix.Dep.Fetcher.do_fetch/3
    (mix 1.12.1) lib/mix/dep/converger.ex:190: Mix.Dep.Converger.all/9
    (mix 1.12.1) lib/mix/dep/converger.ex:123: Mix.Dep.Converger.all/7

When I copy old crypto.so from Erlang 24.2 to 24.3.4.16 installatiion, Rabbitmq builds just fine.

I wonder what was the change which is causing the issue and how to avoid it?

Note in both cases I do use OpenSSL 3.

garazdawi commented 7 months ago

What OS are you running on? What do you get if you run ldd /path/to/crypto*.so?

Just FYI, while OpenSSL 3 may work for you in Erlang/OTP 24, it is not recommended to use until Erlang/OTP 25.

psumbera commented 7 months ago

What OS are you running on? What do you get if you run ldd /path/to/crypto*.so?

The OS is latest Solaris 11.4.

ldd output for both crypto.so modules is the same:

        libcrypto.so.3 =>        /usr/openssl/3/lib/64/libcrypto.so.3
        libc.so.1 =>     /lib/64/libc.so.1
psumbera commented 7 months ago

I have tried to bisect the issue and it says that the first bad commiw was: https://github.com/erlang/otp/commit/5660f1b9da05ce61382454f0fce4a96ee2473f13

psumbera commented 7 months ago

Ok the issue is that Erlang 23.3.4.16 is missing following commit: https://github.com/erlang/otp/commit/5549bf92e6920304ae83af13511b9a1c62ffe71e .

Any chance to get it into 24 branch?

mikpe commented 7 months ago

If you have to use OTP-24 (I assume that 23.3.4.16 is a typo) I would suggest to build Erlang/OTP with a self-built statically-linked openssl-1.x.

psumbera commented 7 months ago

Ops, Yes, it's typo. Fow now I need to use 24.3.4.16 (released last week).