Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
Column

Overview

Asterisk makes extensive use of reference counted objects using the astobj2 API. In certain classes of bugs, the reference count for an object may get erroneously increased - leading to an object never getting reclaimed when its lifetime has ended - or decreased - leading (in the best case) to ERROR messages being reported that a bad magic number has been detected or (in the worse case) invalid memory deallocation. Autodestruct warnings are another case that typically indicate a reference to a channel is still hanging around, preventing its destruction.

Below is an example 'bad magic number' log message:

No Format
astobj2.c: bad magic number for object 0xfb5230. Object is likely destroyed

 

In such cases, its often very useful to determine what in Asterisk manipulated the reference count on the object. The astobj2 API supports creating a reference count log for all objects managed by the API.

In all cases, when providing the refs file to Asterisk developers for debugging purposes you should also be providing them with instructional steps, including configuration, that allows them to reproduce the issue consistently. See the Asterisk Issue Guidelines for more details on submitting an issue.

Note

These instructions apply to Asterisk versions 1.8.28, 11.10.0, 12.3.0, 13.0.0 or greater.

Enabling Reference Count Logs in Asterisk 14+

  1. Set refdebug=yes in asterisk.conf.
  2. Restart Asterisk.
  3. Reproduce the issue for which you need reference count debug.
  4. Shutdown Asterisk using asterisk -rx 'core stop gracefully'.  Other methods of shutdown produce hundreds or thousands of false positives.
  5. Run /var/lib/asterisk/scripts/refcounter.py -f /var/log/asterisk/refs -n > /tmp/refs.txt
  6. Provide bug marshals with the /tmp/refs.txt file. That is, attach the refs.txt file to your JIRA issue.
  7. Make a copy of /var/log/asterisk/refs so you have it if more information is needed.

Enabling Reference Count Logs

  1. Enable REF_DEBUG under Compiler Flags in menuselect.
  2. Recompile.
  3. Re-install Asterisk.
  4. Reproduce the issue for which you need reference count debug.
  5. Shutdown Asterisk using asterisk -rx 'core stop gracefully'.  Other methods of shutdown produce hundreds or thousands of false positives.
  6. Run /var/lib/asterisk/scripts/refcounter.py -f /var/log/asterisk/refs -n > /tmp/refs.txt
  7. Provide bug marshals with the /tmp/refs.txt file. That is, attach the refs.txt file to your JIRA issue.
  8. Make a copy of /var/log/asterisk/refs so you have it if more information is needed.

Note /var/log/asterisk/refs is overwritten on each run of Asterisk.

Column
Panel
titleOn This Page

Table of Contents

...

refcounter.py is only installed to /var/lib/asterisk/scripts/ in versions 1.8.32.0, 11.14.0, 12.7.0, 13.1.0 or higher.  It is also available from the Asterisk source contrib/scripts/refcounter.py.  The log can produce large amounts of data,

...