freeswitch icon indicating copy to clipboard operation
freeswitch copied to clipboard

mod_erlang_event crashes when Erlang node shuts down

Open svh-pad opened this issue 5 years ago • 4 comments

I'm using FreeSWITCH 1.10 and Debian Buster. My dialplan extension is configured in the following way:

    <extension name="padif_ivr">
        <condition field="destination_number" expression="^5000$">
            <action application="erlang" data="freeswitch_call_handler_sup:get_fs_handler paddy@caj"/>
        </condition>
    </extension>

and it basically works - I can control the call from Erlang and things are as expected. The problem I run into is that the moment I shut down my Erlang node, FreeSWITCH crashes:

2020-04-08 08:40:26.115479 [ERR] mod_erlang_event.c:1044 erl_error: status=-1, erl_errno=5 errno=0
2020-04-08 08:40:26.135393 [ERR] mod_erlang_event.c:1075 listener exit: status=-1, erl_errno=5 errno=0

which is a bit inconvenient because I will regularly restart the Erlang node for updates and I want to avoid downtime of the FreeSWITCH server. I haven't been able to find much information on the error number that's referenced. I would be willing to try and contribute a fix (though I'm not very experienced with C) but I don't really know where to start.

svh-pad avatar Apr 08 '20 09:04 svh-pad

Do you have a back trace from the crash dump? I have observed a Freeswitch crash that occurs when reconnecting to an Erlang node that has restarted, maybe it is similar.

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fe551d5dcb5 in read_2byte_package () from /opt/fs/lib/freeswitch/mod/mod_erlang_event.so
(gdb) bt full
#0  0x00007fe551d5dcb5 in read_2byte_package () from /opt/fs/lib/freeswitch/mod/mod_erlang_event.so
No symbol table info available.
#1  0x00007fe551d5fbd0 in ei_accept_tmo () from /opt/fs/lib/freeswitch/mod/mod_erlang_event.so
No symbol table info available.
#2  0x00007fe551d56052 in mod_erlang_event_runtime () at mod_erlang_event.c:2104

Forty-Tw0 avatar Oct 20 '21 16:10 Forty-Tw0

Unfortunately what I added above is all I have at present. I also don't have any running servers in this configuration (using older versions of FreeSWITCH partly because of this issue) so it's a bit tricky to test. How would I obtain the back trace?

svh-pad avatar Jan 17 '22 10:01 svh-pad

@svh-pad may I know the erlang version you were using ? have you had any chance with this issue ?

sisila avatar Oct 07 '22 03:10 sisila

edit 2025/05/10 1923 ET

The issue title is misleading because I do remember when FreeSWITCH used to crash upon the external Erlang node exiting, but this is definitely fixed in v1.10.12.

The mod_erlang_event C-node does exit still when that happens, but FreeSWITCH restarts it right away:

# shutting down external Erlang node here

2025-05-10 22:38:19.363459 90.53% [ERR] mod_erlang_event.c:1050 erl_error: status=-1, erl_errno=5 errno=22
2025-05-10 22:38:19.383677 90.53% [ERR] mod_erlang_event.c:1081 listener exit: status=-1, erl_errno=5 errno=22
2025-05-10 22:38:19.383677 90.53% [DEBUG] mod_erlang_event.c:1150 Connection Closed
2025-05-10 22:38:19.383677 90.53% [DEBUG] mod_erlang_event.c:1401 Session complete, waiting for children

# restarting node then `{ignored_atom, freeswitch@my_server} ! register_event_handler.`

2025-05-10 22:38:38.163667 93.90% [DEBUG] mod_erlang_event.c:2139 Launching listener, connection from node inbound_example@my_server, ip 10.5.0.4
2025-05-10 22:38:38.163667 93.90% [DEBUG] mod_erlang_event.c:1143 Connection Open from 10.5.0.4
2025-05-10 22:38:38.163667 93.90% [DEBUG] mod_erlang_event.c:1018 EI_DEBUG erl_reg_send to ignored_atom
2025-05-10 22:38:38.163667 93.90% [DEBUG] ei_helpers.c:238 Received register_event_handler from ignored_atom
2025-05-10 22:38:38.163667 93.90% [DEBUG] ei_helpers.c:236 Sending ok to <inbound_example@my_server.88.0>

Unfortunately, mod_erlang_event does not seem to be working with v1.10.12 at the moment (see issue https://github.com/signalwire/freeswitch/issues/2808).

toraritte avatar Oct 26 '22 22:10 toraritte