[Home]

Summary:ASTERISK-27861: [patch] res_pjsip_endpoint_identifier_ip: Unregister the module for headers.
Reporter:Alexander Traud (traud)Labels:patch pjsip
Date Opened:2018-05-17 01:56:27Date Closed:2018-05-18 15:19:31
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_pjsip_endpoint_identifier_ip
Versions:13.21.0 15.4.0 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) pjsip_unload_1.patch
Description:This issue was caused by [Commit 8494e78|https://github.com/asterisk/asterisk/commit/8494e78010d8917a4165d877045be34ddc2dda22] (ASTERISK-27491). A new sub-module was introduced, it is registered with res_pjsip and therefore increases the reference count on the needed res_pjsip module. res_pjsip should not go, before it is released. So far so good.

However, this new module does not unregister itself on unload. Therefore, res_pjsip leaks a reference. The attached patch fixes this.

*Steps to Reproduce*
# an UNIX operating system, for example Ubuntu 18.04 LTS
# sudo apt install build-essential pkg-config libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxslt1-dev
# wget downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
# tar -zxf ./asterisk\-*-current.tar.gz
# cd ./asterisk\-*
# ./configure --with-pjproject-bundled
# make menuselect.makeopts
# ./menuselect/menuselect --enable REF_DEBUG
# make
# sudo make install config basic-pbx
# sudo stop service asterisk
# asterisk -cd
# core stop gracefully

*Expected Result*
Asterisk cleanly ending (0).

*Actual Results*
loader.c:652 modules_shutdown: Passing on res_pjsip.so: its use count is 1
loader.c:652 modules_shutdown: Passing on res_pjproject.so: its use count is 1
loader.c:652 modules_shutdown: Passing on res_sorcery_config.so: its use count is 12
loader.c:652 modules_shutdown: Passing on res_sorcery_memory.so: its use count is 2
loader.c:652 modules_shutdown: Passing on res_sorcery_astdb.so: its use count is 2
Some modules could not be unloaded, switching to fast shutdown

*Approach*
When a module leaks, one approach is to look at Menuselect and the dependencies. Every module which is required for another module, is not likely the cause of the leak. For example, the modules res_pjproject and res_sorcery_* are required to run the module res_pjsip. Therefore, the not-null reference count of res_pjsip.c is the likely candidate. Then, I went for the [Reference Counts Log| https://wiki.asterisk.org/wiki/display/AST/Reference+Count+Debugging#ReferenceCountDebugging-EnablingReferenceCountLogs] and looked at res_pjsip.c. Each unbalanced (un)register/(un)load is a candidate for a leak. In this case here, an ast_sip_unregister_endpoint_identifier(.) was missing.

*Note*
This is the third reference count leak I report. With the exception of Asterisk 13.18.0 till Asterisk 13.19.1, {{core stop gracefully}} was broken since Asterisk 13.13 (Nov. 2016). All these could have been found via the command-line interface (CLI). End-users of Asterisk might not be aware that this is a bug or think this bug is not relevant because its symptoms are so obvious. Furthermore, analyzing such bugs afterwards is terrible time consuming because I do not know the area which was worked on. Therefore, I recommend to add a test case so {{core stop gracefully}} works for each release.
Comments:By: Asterisk Team (asteriskteam) 2018-05-17 01:56:28.616-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Friendly Automation (friendly-automation) 2018-05-18 15:19:32.653-0500

Change 9006 merged by Jenkins2:
res_pjsip_endpoint_identifier_ip: Unregister the module for headers.

[https://gerrit.asterisk.org/9006|https://gerrit.asterisk.org/9006]

By: Friendly Automation (friendly-automation) 2018-05-18 15:33:16.796-0500

Change 9007 merged by Jenkins2:
res_pjsip_endpoint_identifier_ip: Unregister the module for headers.

[https://gerrit.asterisk.org/9007|https://gerrit.asterisk.org/9007]

By: Friendly Automation (friendly-automation) 2018-05-18 15:41:56.954-0500

Change 9014 merged by Jenkins2:
res_pjsip_endpoint_identifier_ip: Unregister the module for headers.

[https://gerrit.asterisk.org/9014|https://gerrit.asterisk.org/9014]

By: Friendly Automation (friendly-automation) 2018-05-18 16:42:59.044-0500

Change 9005 merged by Kevin Harwell:
res_pjsip_endpoint_identifier_ip: Unregister the module for headers.

[https://gerrit.asterisk.org/9005|https://gerrit.asterisk.org/9005]