[erlang-bugs] ssl:setopts hangs indefinitely
Michael Gebetsroither
michael@REDACTED
Thu Sep 27 13:19:43 CEST 2012
Hello,
We have a lot of gen_server processes locked up here and we suspect ssl:setopts is the cause.
The erlang vm version used is R15B01 from debian, and i'm currently testing R15B02 packages from esl.
(confirmed, R15B02 from esl also has this problem)
The gen_server hang can be reproduced if we connect from a remote host over ssl to the server and remove the network
plug, during communication. Though we couldn't reproduce the error with a local client.
The hanging gen_server is the server process doing all the communication and housekeeping tasks on the socket.
After applying our fix all locked up gen_server processes are gone, because they now terminate on the 2 seconds timeout
wrapped around ssl:setopts.
IMHO the problematic code part is ssl_connection.erl:242 from R15B02 git tag (thought it seems it is not the root cause,
only the effect).
# ssl_connection.erl:242
set_opts(ConnectionPid, Options) ->
sync_send_all_state_event(ConnectionPid, {set_opts, Options}).
# Backtrace of a hanging gen_server
(testnode@REDACTED)4> Program counter: 0x00007f4318db94d0 (gen:do_call/4 + 576)
CP: 0x0000000000000000 (invalid)
arity = 0
0x00007f431b54b2f0 Return addr 0x00007f431386c4e8 (gen_fsm:sync_send_all_state_event/3 + 128)
y(0) #Ref<0.0.65.195525>
y(1) 'testnode@REDACTED'
y(2) []
y(3) infinity
y(4) {set_opts,[{active,once}]}
y(5) '$gen_sync_all_state_event'
y(6) <0.3933.0>
0x00007f431b54b330 Return addr 0x00007f431389aaa8 (ssl_connection:sync_send_all_state_event/3 + 64)
y(0) infinity
y(1) {set_opts,[{active,once}]}
y(2) <0.3933.0>
y(3) Catch 0x00007f431386c4e8 (gen_fsm:sync_send_all_state_event/3 + 128)
0x00007f431b54b358 Return addr 0x00007f4312fd78b8 (socket_handler:handle_info/2 + 1760)
y(0) Catch 0x00007f431389aac8 (ssl_connection:sync_send_all_state_event/3 + 96)
0x00007f431b54b368 Return addr 0x00007f4318e43218 (gen_server:handle_msg/5 + 1680)
y(0) {state,{sslsocket,new_ssl,<0.3933.0>}, ...}
y(1) {handle_msg return data}
# our fix was wrapping ssl:setopts
ssl_setopts(SslSocket, Options) ->
Ref = erlang:now(),
PPid = self(),
Pid = spawn_link(fun() ->
ssl:setopts(SslSocket, Options),
PPid ! {self(), Ref, ssl_setopts_successful} end),
receive
{Pid, Ref, ssl_setopts_successful} -> ok
after ?SSL_SETOPTS_TIMEOUT ->
erlang:exit({error, timeout, {ssl_setopts, Options}})
end.
Michael Gebetsroither
More information about the erlang-bugs
mailing list