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

VM Aborted on non SMP systems #1490

Closed
alvaropag opened this Issue Oct 25, 2016 · 20 comments

Comments

Projects
None yet
6 participants
@alvaropag
Contributor

alvaropag commented Oct 25, 2016

When using zotonic on a erlang vm without smp support when a normal user try to login the VM is aborted with the error message "enif_send: env==NULL on non-SMP VMAborted". I couldn't find which dep is causing this, but it can be fixed setting "-smp enable" in the file src/scripts/zotonic-debug.

More info can be found on fixing_env_null.

To reproduce this problem, just set "-smp disable" in the file above and start zotonic. The admin user doesn't trigger this error.

System info:
AWS Linux 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Erlang 18.3
Zotonic 0.21.1

Maybe we should enable smp by default?

@mmzeeman

This comment has been minimized.

Show comment
Hide comment
@mmzeeman

mmzeeman Oct 25, 2016

Member

This is caused by the bcrypt nif. It uses enif_send, which is usable only on SMP enabled erlang vm's only.

The problem here is that the erlang vm used here is not build with SMP support. Your underlying platform supports it. It is probably better anyway to use an SMP enabled erlang vm in situations like these.

Member

mmzeeman commented Oct 25, 2016

This is caused by the bcrypt nif. It uses enif_send, which is usable only on SMP enabled erlang vm's only.

The problem here is that the erlang vm used here is not build with SMP support. Your underlying platform supports it. It is probably better anyway to use an SMP enabled erlang vm in situations like these.

@alvaropag

This comment has been minimized.

Show comment
Hide comment
@alvaropag

alvaropag Oct 25, 2016

Contributor

The erlang vm used supports smp but I'm on AWS with a t2.micro instance and 1 vCPU only (free tier), so the erlang vm correctly disable smp support.

Contributor

alvaropag commented Oct 25, 2016

The erlang vm used supports smp but I'm on AWS with a t2.micro instance and 1 vCPU only (free tier), so the erlang vm correctly disable smp support.

@mmzeeman

This comment has been minimized.

Show comment
Hide comment
@mmzeeman

mmzeeman Oct 26, 2016

Member

It looks like it is possible to configure the bcrypt dep to use the port implementation instead of the nif. This probably makes it possible to run zotonic on non-SMP systems.

Check the readme on: https://github.com/smarkets/erlang-bcrypt

Member

mmzeeman commented Oct 26, 2016

It looks like it is possible to configure the bcrypt dep to use the port implementation instead of the nif. This probably makes it possible to run zotonic on non-SMP systems.

Check the readme on: https://github.com/smarkets/erlang-bcrypt

@alvaropag

This comment has been minimized.

Show comment
Hide comment
@alvaropag

alvaropag Oct 26, 2016

Contributor

I don't have any metrics, but isn't the port version generally slower? Maybe we should just add a warning in the docs about non SMP systems and list the options to mitigate this. Then the user chooses what is best according to his specific situation.

Contributor

alvaropag commented Oct 26, 2016

I don't have any metrics, but isn't the port version generally slower? Maybe we should just add a warning in the docs about non SMP systems and list the options to mitigate this. Then the user chooses what is best according to his specific situation.

@mmzeeman

This comment has been minimized.

Show comment
Hide comment
@mmzeeman

mmzeeman Oct 26, 2016

Member

The thing is that bcrypt is slow by design. Therefore the nif version uses the thread implementation in order to avoid scheduler lockups. The port version handles the slow bcrypt operations via separate processes.

@marc, we will probably have to limit the usage of bcrypt for a zotonic node to stop brute force bcrypt calls.

And indeed, there should be a warning somewhere about running on non-SMP system.

Member

mmzeeman commented Oct 26, 2016

The thing is that bcrypt is slow by design. Therefore the nif version uses the thread implementation in order to avoid scheduler lockups. The port version handles the slow bcrypt operations via separate processes.

@marc, we will probably have to limit the usage of bcrypt for a zotonic node to stop brute force bcrypt calls.

And indeed, there should be a warning somewhere about running on non-SMP system.

@mworrell

This comment has been minimized.

Show comment
Hide comment
@mworrell

mworrell Jan 31, 2017

Member

As discussed with @mmzeeman in #1589, I propose to make the port version the default.

It will be added to the erlang.config.in, existing installations need to update their erlang.config file.

{bcrypt,
    [{mechanism, port}, {pool_size, 4}]
 },
Member

mworrell commented Jan 31, 2017

As discussed with @mmzeeman in #1589, I propose to make the port version the default.

It will be added to the erlang.config.in, existing installations need to update their erlang.config file.

{bcrypt,
    [{mechanism, port}, {pool_size, 4}]
 },
@mworrell

This comment has been minimized.

Show comment
Hide comment
@mworrell

mworrell Jan 31, 2017

Member

Problem: rebar3 doesn't seem to build priv/bcrypt, which is needed for the port.

With rebar2 it is build, so it is a problem with the rebar3 compatibility.

Added an issue with bcrypt, hopefully someone knows a solution, see smarkets/erlang-bcrypt#17

Member

mworrell commented Jan 31, 2017

Problem: rebar3 doesn't seem to build priv/bcrypt, which is needed for the port.

With rebar2 it is build, so it is a problem with the rebar3 compatibility.

Added an issue with bcrypt, hopefully someone knows a solution, see smarkets/erlang-bcrypt#17

@mworrell mworrell added the defect label Jan 31, 2017

@heiheshang

This comment has been minimized.

Show comment
Hide comment
@heiheshang

heiheshang Feb 1, 2017

I could not get
zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-01 04:31:25 =ERROR REPORT==== zotonic | Can't open file "/srv/zotonic/_build/default/lib/bcrypt/priv/bcrypt": enoent zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-01 04:31:25.152 [warning] <0.30.0> lager_error_logger_h dropped 245 messages in the last second that exceeded the limit of 50 messages/sec zotonic | 2017-02-01 04:31:25.152 [error] <0.1696.0> Can't open file "/srv/zotonic/_build/default/lib/bcrypt/priv/bcrypt": enoent zotonic | zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-01 04:31:25 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_port:init/1 zotonic | pid: <0.1696.0> zotonic | registered_name: [] zotonic | exception exit: {error_opening_bcrypt_file,[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,344}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_port_sup,bcrypt_sup,<0.284.0>] zotonic | messages: [] zotonic | links: [<0.286.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 376 zotonic | stack_size: 27 zotonic | reductions: 190 zotonic | neighbours: zotonic | 2017-02-01 04:31:25 =ERROR REPORT==== zotonic | ** Generic server bcrypt_pool terminating zotonic | ** Last message in was request zotonic | ** When Server state == {state,4,0,{[],[]},{[],[]}} zotonic | ** Reason for termination == zotonic | ** {function_clause,[{bcrypt_pool,terminate,[{{badmatch,{error,error_opening_bcrypt_file}},[{bcrypt_pool,handle_call,3,[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,44}]},{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,615}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},{state,4,0,{[],[]},{[],[]}}],[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,36}]},{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | 2017-02-01 04:31:25 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_pool:init/1 zotonic | pid: <0.287.0> zotonic | registered_name: bcrypt_pool zotonic | exception exit: {{function_clause,[{bcrypt_pool,terminate,[{{badmatch,{error,error_opening_bcrypt_file}},[{bcrypt_pool,handle_call,3,[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,44}]},{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,615}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},{state,4,0,{[],[]},{[],[]}}],[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,36}]},{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},[{gen_server,terminate,7,[{file,"gen_server.erl"},{line,800}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_sup,<0.284.0>] zotonic | messages: [] zotonic | links: [<0.285.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 987 zotonic | stack_size: 27 zotonic | reductions: 218 zotonic | neighbours: zotonic | 2017-02-01 04:31:25 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_sup} zotonic | Context: child_terminated zotonic | Reason: {function_clause,[{bcrypt_pool,terminate,[{{badmatch,{error,error_opening_bcrypt_file}},[{bcrypt_pool,handle_call,3,[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,44}]},{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,615}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},{state,4,0,{[],[]},{[],[]}}],[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,36}]},{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | Offender: [{pid,<0.287.0>},{id,bcrypt_pool},{mfargs,{bcrypt_pool,start_link,[]}},{restart_type,permanent},{shutdown,4294967295},{child_type,worker}]

heiheshang commented Feb 1, 2017

I could not get
zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-01 04:31:25 =ERROR REPORT==== zotonic | Can't open file "/srv/zotonic/_build/default/lib/bcrypt/priv/bcrypt": enoent zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-01 04:31:25.152 [warning] <0.30.0> lager_error_logger_h dropped 245 messages in the last second that exceeded the limit of 50 messages/sec zotonic | 2017-02-01 04:31:25.152 [error] <0.1696.0> Can't open file "/srv/zotonic/_build/default/lib/bcrypt/priv/bcrypt": enoent zotonic | zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-01 04:31:25 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_port:init/1 zotonic | pid: <0.1696.0> zotonic | registered_name: [] zotonic | exception exit: {error_opening_bcrypt_file,[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,344}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_port_sup,bcrypt_sup,<0.284.0>] zotonic | messages: [] zotonic | links: [<0.286.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 376 zotonic | stack_size: 27 zotonic | reductions: 190 zotonic | neighbours: zotonic | 2017-02-01 04:31:25 =ERROR REPORT==== zotonic | ** Generic server bcrypt_pool terminating zotonic | ** Last message in was request zotonic | ** When Server state == {state,4,0,{[],[]},{[],[]}} zotonic | ** Reason for termination == zotonic | ** {function_clause,[{bcrypt_pool,terminate,[{{badmatch,{error,error_opening_bcrypt_file}},[{bcrypt_pool,handle_call,3,[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,44}]},{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,615}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},{state,4,0,{[],[]},{[],[]}}],[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,36}]},{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | 2017-02-01 04:31:25 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_pool:init/1 zotonic | pid: <0.287.0> zotonic | registered_name: bcrypt_pool zotonic | exception exit: {{function_clause,[{bcrypt_pool,terminate,[{{badmatch,{error,error_opening_bcrypt_file}},[{bcrypt_pool,handle_call,3,[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,44}]},{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,615}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},{state,4,0,{[],[]},{[],[]}}],[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,36}]},{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},[{gen_server,terminate,7,[{file,"gen_server.erl"},{line,800}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_sup,<0.284.0>] zotonic | messages: [] zotonic | links: [<0.285.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 987 zotonic | stack_size: 27 zotonic | reductions: 218 zotonic | neighbours: zotonic | 2017-02-01 04:31:25 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_sup} zotonic | Context: child_terminated zotonic | Reason: {function_clause,[{bcrypt_pool,terminate,[{{badmatch,{error,error_opening_bcrypt_file}},[{bcrypt_pool,handle_call,3,[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,44}]},{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,615}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},{state,4,0,{[],[]},{[],[]}}],[{file,"/srv/zotonic/_build/default/lib/bcrypt/src/bcrypt_pool.erl"},{line,36}]},{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | Offender: [{pid,<0.287.0>},{id,bcrypt_pool},{mfargs,{bcrypt_pool,start_link,[]}},{restart_type,permanent},{shutdown,4294967295},{child_type,worker}]

@mworrell

This comment has been minimized.

Show comment
Hide comment
@mworrell

mworrell Feb 1, 2017

Member

Yes, that is the build problem I referred to above. Somehow the bcrypt executable is not built with rebar3. A workaround is to run make in the brcrypt directory with rebar2 on your search path.

We didn't seem to find anyone who fixed this issue in their fork.

I am waiting if the maintainer of the branch we are using reacts, otherwise we need to investigate other solutions.

Member

mworrell commented Feb 1, 2017

Yes, that is the build problem I referred to above. Somehow the bcrypt executable is not built with rebar3. A workaround is to run make in the brcrypt directory with rebar2 on your search path.

We didn't seem to find anyone who fixed this issue in their fork.

I am waiting if the maintainer of the branch we are using reacts, otherwise we need to investigate other solutions.

@heiheshang

This comment has been minimized.

Show comment
Hide comment
@heiheshang

heiheshang Feb 3, 2017

I tried to gather under bcrypt rebar3.everything is going fine.

[oper@heiheshang erlang-bcrypt]# rebar3 compile
===> Fetching pc ({pkg,<<"pc">>,<<"1.5.0">>})
===> Downloaded package, caching at /oper/.cache/rebar3/hex/default/packages/pc-1.5.0.tar
===> Compiling pc
===> Verifying dependencies...
===> Compiling bcrypt
===> Compiling /home/erlang-bcrypt/c_src/async_queue.c
===> Compiling /home/erlang-bcrypt/c_src/bcrypt.c
===> Compiling /home/erlang-bcrypt/c_src/bcrypt_nif.c
===> Compiling /home/erlang-bcrypt/c_src/bcrypt_port.c
===> Compiling /home/erlang-bcrypt/c_src/blowfish.c
===> Linking /home/erlang-bcrypt/priv/bcrypt_nif.so
src/bcrypt_nif.erl:57: Warning: crypto:rand_bytes/1 is deprecated and will be removed in a future release; use crypto:strong_rand_bytes/1

src/bcrypt_port.erl:42: Warning: crypto:rand_bytes/1 is deprecated and will be removed in a future release; use crypto:strong_rand_bytes/1
src/bcrypt_port.erl:46: Warning: crypto:rand_bytes/1 is deprecated and will be removed in a future release; use crypto:strong_rand_bytes/1

heiheshang commented Feb 3, 2017

I tried to gather under bcrypt rebar3.everything is going fine.

[oper@heiheshang erlang-bcrypt]# rebar3 compile
===> Fetching pc ({pkg,<<"pc">>,<<"1.5.0">>})
===> Downloaded package, caching at /oper/.cache/rebar3/hex/default/packages/pc-1.5.0.tar
===> Compiling pc
===> Verifying dependencies...
===> Compiling bcrypt
===> Compiling /home/erlang-bcrypt/c_src/async_queue.c
===> Compiling /home/erlang-bcrypt/c_src/bcrypt.c
===> Compiling /home/erlang-bcrypt/c_src/bcrypt_nif.c
===> Compiling /home/erlang-bcrypt/c_src/bcrypt_port.c
===> Compiling /home/erlang-bcrypt/c_src/blowfish.c
===> Linking /home/erlang-bcrypt/priv/bcrypt_nif.so
src/bcrypt_nif.erl:57: Warning: crypto:rand_bytes/1 is deprecated and will be removed in a future release; use crypto:strong_rand_bytes/1

src/bcrypt_port.erl:42: Warning: crypto:rand_bytes/1 is deprecated and will be removed in a future release; use crypto:strong_rand_bytes/1
src/bcrypt_port.erl:46: Warning: crypto:rand_bytes/1 is deprecated and will be removed in a future release; use crypto:strong_rand_bytes/1
@mworrell

This comment has been minimized.

Show comment
Hide comment
@mworrell

mworrell Feb 3, 2017

Member

Interesting, so priv/bcrypt is not build if we build bcrypt as a dependency, but it is build if building it directly inside the bcrypt directory.

Did you check the priv directory if both the .so and the bcrypt executable are build?

Member

mworrell commented Feb 3, 2017

Interesting, so priv/bcrypt is not build if we build bcrypt as a dependency, but it is build if building it directly inside the bcrypt directory.

Did you check the priv directory if both the .so and the bcrypt executable are build?

@heiheshang

This comment has been minimized.

Show comment
Hide comment
@heiheshang

heiheshang Feb 3, 2017

rebar3 gather with zotonic file, but the file is placed in the prev folder bcrypt module seeks to bcrypt in catalog.I made the necessary directories and now zotonic falls fatally,but still it does not work properly
zotonic | zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-03 15:49:27 =ERROR REPORT==== zotonic | ** Generic server <0.8438.0> terminating zotonic | ** Last message in was {#Port<0.28418>,{exit_status,126}} zotonic | ** When Server state == {state,#Port<0.28418>,12} zotonic | ** Reason for termination == zotonic | ** port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.724 [warning] <0.8438.0> Port died: 126 zotonic | 2017-02-03 15:49:27.724 [error] <0.8438.0> gen_server <0.8438.0> terminated with reason: port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-03 15:49:27 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_port:init/1 zotonic | pid: <0.8438.0> zotonic | registered_name: [] zotonic | exception exit: {port_died,[{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_port_sup,bcrypt_sup,<0.275.0>] zotonic | messages: [] zotonic | links: [<0.7485.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 610 zotonic | stack_size: 27 zotonic | reductions: 257 zotonic | neighbours: zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_port_sup} zotonic | Context: child_terminated zotonic | Reason: port_died zotonic | Offender: [{pid,<0.8438.0>},{id,undefined},{mfargs,{bcrypt_port,start_link,[]}},{restart_type,transient},{shutdown,brutal_kill},{child_type,worker}] zotonic | zotonic | 2017-02-03 15:49:27 =ERROR REPORT==== zotonic | ** Generic server <0.8439.0> terminating zotonic | ** Last message in was {#Port<0.28419>,{exit_status,126}} zotonic | ** When Server state == {state,#Port<0.28419>,12} zotonic | ** Reason for termination == zotonic | ** port_died zotonic | 2017-02-03 15:49:27 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_port:init/1 zotonic | pid: <0.8439.0> zotonic | registered_name: [] zotonic | exception exit: {port_died,[{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_port_sup,bcrypt_sup,<0.275.0>] zotonic | messages: [] zotonic | links: [<0.7485.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 376 zotonic | stack_size: 27 zotonic | reductions: 229 zotonic | neighbours: zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_port_sup} zotonic | Context: child_terminated zotonic | Reason: port_died zotonic | Offender: [{pid,<0.8439.0>},{id,undefined},{mfargs,{bcrypt_port,start_link,[]}},{restart_type,transient},{shutdown,brutal_kill},{child_type,worker}] zotonic | zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_port_sup} zotonic | Context: shutdown zotonic | Reason: reached_max_restart_intensity zotonic | Offender: [{pid,<0.8439.0>},{id,undefined},{mfargs,{bcrypt_port,start_link,[]}},{restart_type,transient},{shutdown,brutal_kill},{child_type,worker}] zotonic | zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_sup} zotonic | Context: child_terminated zotonic | Reason: shutdown zotonic | Offender: [{pid,<0.7485.0>},{id,bcrypt_port_sup},{mfargs,{bcrypt_port_sup,start_link,[]}},{restart_type,permanent},{shutdown,4294967295},{child_type,supervisor}] zotonic | zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.724 [error] <0.8438.0> gen_server <0.8438.0> terminated with reason: port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.8438.0> CRASH REPORT Process <0.8438.0> with 0 neighbours exited with reason: port_died in gen_server:terminate/7 line 812 zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.8438.0> CRASH REPORT Process <0.8438.0> with 0 neighbours exited with reason: port_died in gen_server:terminate/7 line 812 zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.7485.0> Supervisor bcrypt_port_sup had child undefined started with bcrypt_port:start_link() at <0.8438.0> exit with reason port_died in context child_terminated zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.7485.0> Supervisor bcrypt_port_sup had child undefined started with bcrypt_port:start_link() at <0.8438.0> exit with reason port_died in context child_terminated zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.730 [warning] <0.8439.0> Port died: 126 zotonic | 2017-02-03 15:49:27.730 [error] <0.8439.0> gen_server <0.8439.0> terminated with reason: port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.730 [error] <0.8439.0> gen_server <0.8439.0> terminated with reason: port_died

heiheshang commented Feb 3, 2017

rebar3 gather with zotonic file, but the file is placed in the prev folder bcrypt module seeks to bcrypt in catalog.I made the necessary directories and now zotonic falls fatally,but still it does not work properly
zotonic | zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-03 15:49:27 =ERROR REPORT==== zotonic | ** Generic server <0.8438.0> terminating zotonic | ** Last message in was {#Port<0.28418>,{exit_status,126}} zotonic | ** When Server state == {state,#Port<0.28418>,12} zotonic | ** Reason for termination == zotonic | ** port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.724 [warning] <0.8438.0> Port died: 126 zotonic | 2017-02-03 15:49:27.724 [error] <0.8438.0> gen_server <0.8438.0> terminated with reason: port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/crash.log <== zotonic | 2017-02-03 15:49:27 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_port:init/1 zotonic | pid: <0.8438.0> zotonic | registered_name: [] zotonic | exception exit: {port_died,[{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_port_sup,bcrypt_sup,<0.275.0>] zotonic | messages: [] zotonic | links: [<0.7485.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 610 zotonic | stack_size: 27 zotonic | reductions: 257 zotonic | neighbours: zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_port_sup} zotonic | Context: child_terminated zotonic | Reason: port_died zotonic | Offender: [{pid,<0.8438.0>},{id,undefined},{mfargs,{bcrypt_port,start_link,[]}},{restart_type,transient},{shutdown,brutal_kill},{child_type,worker}] zotonic | zotonic | 2017-02-03 15:49:27 =ERROR REPORT==== zotonic | ** Generic server <0.8439.0> terminating zotonic | ** Last message in was {#Port<0.28419>,{exit_status,126}} zotonic | ** When Server state == {state,#Port<0.28419>,12} zotonic | ** Reason for termination == zotonic | ** port_died zotonic | 2017-02-03 15:49:27 =CRASH REPORT==== zotonic | crasher: zotonic | initial call: bcrypt_port:init/1 zotonic | pid: <0.8439.0> zotonic | registered_name: [] zotonic | exception exit: {port_died,[{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]} zotonic | ancestors: [bcrypt_port_sup,bcrypt_sup,<0.275.0>] zotonic | messages: [] zotonic | links: [<0.7485.0>] zotonic | dictionary: [] zotonic | trap_exit: false zotonic | status: running zotonic | heap_size: 376 zotonic | stack_size: 27 zotonic | reductions: 229 zotonic | neighbours: zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_port_sup} zotonic | Context: child_terminated zotonic | Reason: port_died zotonic | Offender: [{pid,<0.8439.0>},{id,undefined},{mfargs,{bcrypt_port,start_link,[]}},{restart_type,transient},{shutdown,brutal_kill},{child_type,worker}] zotonic | zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_port_sup} zotonic | Context: shutdown zotonic | Reason: reached_max_restart_intensity zotonic | Offender: [{pid,<0.8439.0>},{id,undefined},{mfargs,{bcrypt_port,start_link,[]}},{restart_type,transient},{shutdown,brutal_kill},{child_type,worker}] zotonic | zotonic | 2017-02-03 15:49:27 =SUPERVISOR REPORT==== zotonic | Supervisor: {local,bcrypt_sup} zotonic | Context: child_terminated zotonic | Reason: shutdown zotonic | Offender: [{pid,<0.7485.0>},{id,bcrypt_port_sup},{mfargs,{bcrypt_port_sup,start_link,[]}},{restart_type,permanent},{shutdown,4294967295},{child_type,supervisor}] zotonic | zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.724 [error] <0.8438.0> gen_server <0.8438.0> terminated with reason: port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.8438.0> CRASH REPORT Process <0.8438.0> with 0 neighbours exited with reason: port_died in gen_server:terminate/7 line 812 zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.8438.0> CRASH REPORT Process <0.8438.0> with 0 neighbours exited with reason: port_died in gen_server:terminate/7 line 812 zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.7485.0> Supervisor bcrypt_port_sup had child undefined started with bcrypt_port:start_link() at <0.8438.0> exit with reason port_died in context child_terminated zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.725 [error] <0.7485.0> Supervisor bcrypt_port_sup had child undefined started with bcrypt_port:start_link() at <0.8438.0> exit with reason port_died in context child_terminated zotonic | zotonic | ==> /srv/zotonic/priv/log/console.log <== zotonic | 2017-02-03 15:49:27.730 [warning] <0.8439.0> Port died: 126 zotonic | 2017-02-03 15:49:27.730 [error] <0.8439.0> gen_server <0.8439.0> terminated with reason: port_died zotonic | zotonic | ==> /srv/zotonic/priv/log/error.log <== zotonic | 2017-02-03 15:49:27.730 [error] <0.8439.0> gen_server <0.8439.0> terminated with reason: port_died

@ddeboer

This comment has been minimized.

Show comment
Hide comment
@ddeboer

ddeboer Feb 22, 2017

Member

Solution is forthcoming in smarkets/erlang-bcrypt#18.

Member

ddeboer commented Feb 22, 2017

Solution is forthcoming in smarkets/erlang-bcrypt#18.

@mworrell

This comment has been minimized.

Show comment
Hide comment
@mworrell

mworrell Feb 22, 2017

Member

if the bcrypt build solution is merged, can we then add some runtime switch? We can see that there is only a single core running.

Member

mworrell commented Feb 22, 2017

if the bcrypt build solution is merged, can we then add some runtime switch? We can see that there is only a single core running.

@ddeboer

This comment has been minimized.

Show comment
Hide comment
@ddeboer

ddeboer Jun 28, 2017

Member

Published a fixed bcrypt to Hex: 1.0.0.

Member

ddeboer commented Jun 28, 2017

Published a fixed bcrypt to Hex: 1.0.0.

@ddeboer

This comment has been minimized.

Show comment
Hide comment
@ddeboer

ddeboer Aug 16, 2017

Member

See also #1613:

@mmzeeman Zotonic now uses bcrypt from ErlangPack, in which I’ve included the Rebar3 fix. We should now be able to use the mechanism configuration to switch to port. Do we still want to do this by default in Zotonic?

Additionally, would there be any difference in performance between port and nif for bcrypt?

Member

ddeboer commented Aug 16, 2017

See also #1613:

@mmzeeman Zotonic now uses bcrypt from ErlangPack, in which I’ve included the Rebar3 fix. We should now be able to use the mechanism configuration to switch to port. Do we still want to do this by default in Zotonic?

Additionally, would there be any difference in performance between port and nif for bcrypt?

@CyBeRoni

This comment has been minimized.

Show comment
Hide comment
@CyBeRoni

CyBeRoni Aug 24, 2017

Contributor

Since the point of bcrypt is to be slow, I think that would be a good thing?

Contributor

CyBeRoni commented Aug 24, 2017

Since the point of bcrypt is to be slow, I think that would be a good thing?

@ddeboer

This comment has been minimized.

Show comment
Hide comment
@ddeboer

ddeboer Aug 24, 2017

Member

Sure, you want a crypt lib to be slow, but not needlessly so. If port adds a lot of overhead compared to nif while still giving the same encryption (as it executes the same C code), that’s not a good thing.

Member

ddeboer commented Aug 24, 2017

Sure, you want a crypt lib to be slow, but not needlessly so. If port adds a lot of overhead compared to nif while still giving the same encryption (as it executes the same C code), that’s not a good thing.

@mmzeeman

This comment has been minimized.

Show comment
Hide comment
@mmzeeman

mmzeeman Aug 25, 2017

Member

The port version is better if you handle a lot of logins. Because bcrypt is slow the nif will throw off the erlang schedulers when used (as it is not async in a separate thread). Not a problem for the occasional call every now and then, but it will be if it is called more frequently.

Member

mmzeeman commented Aug 25, 2017

The port version is better if you handle a lot of logins. Because bcrypt is slow the nif will throw off the erlang schedulers when used (as it is not async in a separate thread). Not a problem for the occasional call every now and then, but it will be if it is called more frequently.

@mworrell

This comment has been minimized.

Show comment
Hide comment
@mworrell

mworrell Oct 13, 2017

Member

Soon, OTP won't support non-SMP systems anymore.

Is there anything we need to do to close this issue?
Do we need to change the way we use bcrypt?

Member

mworrell commented Oct 13, 2017

Soon, OTP won't support non-SMP systems anymore.

Is there anything we need to do to close this issue?
Do we need to change the way we use bcrypt?

mworrell added a commit that referenced this issue Nov 6, 2017

@mworrell mworrell closed this Nov 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment