Hello
I'm trying to debug a simple Phoenix app. I'm at the point where I'm just creating a simple user login API and using comeonin for the hashing. Interestingly, when I run mix phx.server from the terminal, I can run everything just fine. However, when I debug using the intellij plugin (which despite the issues is still wonderful and amazing by the way), I get this:
ErlangError at POST /api/users
Erlang error: :not_loaded
nofile
No code available.
:erlang.nif_error/1
Called with 1 arguments
:not_loaded
Elixir.Comeonin.Bcrypt.erl
137 @doc """
138 Initialize the P-box and S-box tables with the digits of Pi,
139 and then start the key expansion process.
140 """
141 def bf_init(key, key_len, salt)
142 def bf_init(_, _, _), do: :erlang.nif_error(:not_loaded)
143
144 @doc """
145 The main key expansion function. This function is called
146 2^log_rounds times.
147 """
Comeonin.Bcrypt.bf_init/3 docs comeonin
Elixir.Comeonin.Bcrypt.erl
161 end
162
163 defp bcrypt(key, salt, prefix, log_rounds) when prefix in ['2b', '2a'] do
164 key_len = if prefix == '2b' and length(key) > 72, do: 73, else: length(key) + 1
165 {salt, rounds} = prepare_keys(salt, List.to_integer(log_rounds))
166 bf_init(key, key_len, salt)
167 |> expand_keys(key, key_len, salt, rounds)
168 |> bf_encrypt
169 end
I've already tried setting this environment variable:
INTELLIJ_ELIXIR_DEBUG_BLACKLIST=Elixir.Bcrypt.Base,Elixir.Bcrypt.Stats,Elixir.Bcrypt,bcrypt_elixir,iconv,comeonin
but I wasn't sure if that was what was causing issue.
The specific function call is Comeonin.Bcrypt.hashpwsalt(password)
Version Info:
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.5.1
OS: Lubunu 17.04
I'm new to Elixir/Erlang so any help is appreciated.
Thanks
Is the repo public, so I can fork it and use it as a test case?
It'd be great if there were a way to detect which modules have NIFs so we can avoid auto-intepreting them, but unfortunately, I'm not aware of any way to do that.
If NIFs work the way C extensions do in other languages, there will be a trampoline in the .beam that gets rewritten to a direct call to the C once the VM can see the .so or .dll. I bet there's some way to figure that out when decompiling the .beam.
Just wanted to say I have the same issue with comeonin/bcrypt and IntelliJ-Elixir.
@KronicDeth If you want to repro you can use the "Programming Phoenix" example app: https://github.com/terakilobyte/rumbl
Putting a debug point on this line: https://github.com/terakilobyte/rumbl/blob/master/web/models/user.ex#L34 and then trying to sign up will trigger this error (I also get it in my own application on any file that calls the same comeonin function)
Most helpful comment
Just wanted to say I have the same issue with comeonin/bcrypt and IntelliJ-Elixir.
@KronicDeth If you want to repro you can use the "Programming Phoenix" example app: https://github.com/terakilobyte/rumbl
Putting a debug point on this line: https://github.com/terakilobyte/rumbl/blob/master/web/models/user.ex#L34 and then trying to sign up will trigger this error (I also get it in my own application on any file that calls the same comeonin function)