[Freeswitch-dev] FreeSWITCH Windows Crash due to Detached Threads (and solution)
Hi, Under Windows, FreeSWITCH consistently crashes with all default install setting after issuing the ‘shutdown’ command from console immediately after startup, without a single call handled. Note that on my servers, this only happens in ‘Release’ version, not in ‘Debug’. The problem is due to “problematic” Windows thread handling. I noticed that all FS threads are ‘detachable’ and not ‘joinable’. When an application with active detached threads terminates, a race condition can lead to the application crash, as shown in the sample application at http://pastebin.freeswitch.org/7225 . This is exactly what causes FS to crash as a result of the mod_event_socket detached runtime thread. A temporary workaround is to change in switch_loadable_module_exec() the call to switch_yield(1000000) with switch_thread_exit(thread, 0). In my case it solved the crash, but theoretically it does not always solve the problem, because there is no guarantee that it will get called before the main thread reaches its termination code. I think the only safe solution is to use ‘joinable’ threads. Is there a good reason they’re not used? Note – this problem was reported to jira about a month ago http://jira.freeswitch.org/browse/MODEVENT-37 but it seems it was ignored. Thanks, Ron
On Feb 15, 2009, at 9:49 AM, Ron Avriel wrote:
Hi,
Under Windows, FreeSWITCH consistently crashes with all default install setting after issuing the ‘shutdown’ command from console immediately after startup, without a single call handled. Note that on my servers, this only happens in ‘Release’ version, not in ‘Debug’.
The problem is due to “problematic” Windows thread handling. I noticed that all FS threads are ‘detachable’ and not ‘joinable’. When an application with active detached threads terminates, a race condition can lead to the application crash, as shown in the sample application at http://pastebin.freeswitch.org/7225 .
This is exactly what causes FS to crash as a result of the mod_event_socket detached runtime thread.
A temporary workaround is to change in switch_loadable_module_exec() the call to switch_yield(1000000) with switch_thread_exit(thread, 0).
In my case it solved the crash, but theoretically it does not always solve the problem, because there is no guarantee that it will get called before the main thread reaches its termination code.
I think the only safe solution is to use ‘joinable’ threads. Is there a good reason they’re not used?
Note – this problem was reported to jira about a month ago http://jira.freeswitch.org/browse/MODEVENT-37 but it seems it was ignored.
The issue has not been ignored, it just has not been resolved yet. Please put these details on that bug, I'll take a look. Mike
Hi Ron, don't know if it's always like that, but I can confirm I had to use joinable thread for Skypiax to have a reliable "killability" without crashes on Windows (on the Debug build, not cheked on Release). Sincerely, Giovanni Maruzzelli ========================================= www.celliax.org via Pierlombardo 9, 20135 Milano Italy gmaruzz at celliax dot org Cell : +39-347-2665618 Fax : +39-02-87390039 On Sun, Feb 15, 2009 at 3:49 PM, Ron Avriel <ravriel_1@yahoo.com> wrote:
Hi,
Under Windows, FreeSWITCH consistently crashes with all default install setting after issuing the 'shutdown' command from console immediately after startup, without a single call handled. Note that on my servers, this only happens in 'Release' version, not in 'Debug'.
The problem is due to "problematic" Windows thread handling. I noticed that all FS threads are 'detachable' and not 'joinable'. When an application with active detached threads terminates, a race condition can lead to the application crash, as shown in the sample application at http://pastebin.freeswitch.org/7225 .
This is exactly what causes FS to crash as a result of the mod_event_socket detached runtime thread.
A temporary workaround is to change in switch_loadable_module_exec() the call to switch_yield(1000000) with switch_thread_exit(thread, 0).
In my case it solved the crash, but theoretically it does not always solve the problem, because there is no guarantee that it will get called before the main thread reaches its termination code.
I think the only safe solution is to use 'joinable' threads. Is there a good reason they're not used?
Note – this problem was reported to jira about a month ago http://jira.freeswitch.org/browse/MODEVENT-37 but it seems it was ignored.
Thanks, Ron
_______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Saying that we are ignoring an issue, considering the workload we have, is not the best way to open a conversation. If you are willing to work on this issue and volunteer your time and efforts to get a more long term solution. please contact us. On Sun, Feb 15, 2009 at 11:30 AM, Giovanni Maruzzelli <gmaruzz@celliax.org>wrote:
Hi Ron,
don't know if it's always like that, but I can confirm I had to use joinable thread for Skypiax to have a reliable "killability" without crashes on Windows (on the Debug build, not cheked on Release).
Sincerely,
Giovanni Maruzzelli ========================================= www.celliax.org via Pierlombardo 9, 20135 Milano Italy gmaruzz at celliax dot org Cell : +39-347-2665618 Fax : +39-02-87390039
On Sun, Feb 15, 2009 at 3:49 PM, Ron Avriel <ravriel_1@yahoo.com> wrote:
Hi,
Under Windows, FreeSWITCH consistently crashes with all default install setting after issuing the 'shutdown' command from console immediately after startup, without a single call handled. Note that on my servers, this only happens in 'Release' version, not in 'Debug'.
The problem is due to "problematic" Windows thread handling. I noticed that all FS threads are 'detachable' and not 'joinable'. When an application with active detached threads terminates, a race condition can lead to the application crash, as shown in the sample application at http://pastebin.freeswitch.org/7225 .
This is exactly what causes FS to crash as a result of the mod_event_socket detached runtime thread.
A temporary workaround is to change in switch_loadable_module_exec() the call to switch_yield(1000000) with switch_thread_exit(thread, 0).
In my case it solved the crash, but theoretically it does not always solve the problem, because there is no guarantee that it will get called before the main thread reaches its termination code.
I think the only safe solution is to use 'joinable' threads. Is there a good reason they're not used?
Note – this problem was reported to jira about a month ago http://jira.freeswitch.org/browse/MODEVENT-37 but it seems it was ignored.
Thanks, Ron
_______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
participants (4)
-
Anthony Minessale
-
Giovanni Maruzzelli
-
Michael Jerris
-
Ron Avriel