[Asterisk-code-review] chan sip: Don't unload module while TCP/TLS threads are stil... (asterisk[master])

Michael Kuron asteriskteam at digium.com
Wed Nov 30 13:40:10 CST 2016


Michael Kuron has posted comments on this change. ( https://gerrit.asterisk.org/4536 )

Change subject: chan_sip: Don't unload module while TCP/TLS threads are still running
......................................................................


Patch Set 1:

This change is a follow-up to https://gerrit.asterisk.org/#/c/4494/. Removing the SA_RESTART flag from the SIGURG handler in that commit fixed one specific kind of race condition segfault. It did not fix the underlying issue (chan_sip being unloaded while threads were still using it). This commit does so, which should fix some race conditions that are less easy to trigger. One such race condition would be this one: module unload chan_sip is executed, a TCP connection is made and a thread is created for it, but the unload_module function sends pthread_kill(..., SIGURG) to the thread before the thread has reached ast_connect(). SIGURG never has any effect in that case and the library is unloaded while the thread is still running (albeit blocked con connect()). The thread eventually tries to return control to a function from chan_sip when the connect timeout is reached, but that function is no longer in memory, so we have a segfault.

The SA_RESTART fix from the other patch is still necessary: without it, it is much more likely that we need to wait for TCP connect to time out before we can complete the unload.

-- 
To view, visit https://gerrit.asterisk.org/4536
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I23a8abf9e8f73b57ff7ada61984b8506aea6cbde
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Michael Kuron <m.kuron at gmx.de>
Gerrit-Reviewer: Michael Kuron <m.kuron at gmx.de>
Gerrit-HasComments: No



More information about the asterisk-code-review mailing list