Summary:ASTERISK-21391: Asterisk fails to load chan_sip.so after compiling with "#define REF_DEBUG 1" in chan_sip.c
Reporter:Rusty Newton (rnewton)Labels:
Date Opened:2013-04-08 21:03:36Date Closed:2013-04-09 09:28:20
Versions:11.3.0 Frequency of
Description:Following the guide at https://wiki.asterisk.org/wiki/display/AST/Reference+Count+Debugging for chan_sip results in chan_sip failing to load:

[Apr  8 21:00:11] WARNING[20719]: loader.c:486 load_dynamic_module: Error loading module 'chan_sip.so': /usr/lib/asterisk/modules/chan_sip.so: undefined symbol: sip_unref_peer
[Apr  8 21:00:11] WARNING[20719]: loader.c:902 load_resource: Module 'chan_sip.so' could not be loaded.

No other relevant messages of any type around the time of attempted load with VERBOSE and DEBUG turned up to 5.
Comments:By: Rusty Newton (rnewton) 2013-04-08 21:06:13.120-0500

Reporter for a different issue, ASTERISK-21047, found the issue when troubleshooting. I reproduced.

By: Matt Jordan (mjordan) 2013-04-09 09:28:14.546-0500

Unlike Asterisk 1.8, Asterisk 11 has the SIP security event framework that was added in Asterisk 10. The SIP Security Event Framework exists in a separate file from {{channels/chan_sip.c}} - {{channels/sip/security_events.c}}. The security event code also uses {{ao2}} objects and is compiled into {{chan_sip}}. If you don't enable {{REF_DEBUG}} in *both* files, you get an undefined symbol error, as {{security_events.c}} will still be attempting to access the non-REF_DEBUG version of the functions that modify the reference count on peers.

Note that this is documented in Asterisk 11's {{chan_sip.c}}, right above the {{REF_DEBUG}} comment:

  Note: This must also be enabled in channels/sip/security_events.c
#define  REF_DEBUG 1

This probably just needs to be updated on the wiki.

By: Rusty Newton (rnewton) 2013-04-09 18:42:04.469-0500

https://wiki.asterisk.org/wiki/display/AST/Reference+Count+Debugging is now updated!  Thanks Matt!