summaryrefslogtreecommitdiff
path: root/main/astobj2.c
diff options
context:
space:
mode:
authorScott Griepentrog <sgriepentrog@digium.com>2014-07-18 17:55:38 +0000
committerScott Griepentrog <sgriepentrog@digium.com>2014-07-18 17:55:38 +0000
commit0a99e4099b66a026f8c69d22d382e5e30ebe6f5e (patch)
tree34ab43871aa4b0cb5665ace35e3fc9bd5f094b74 /main/astobj2.c
parentf91989d44ee5ee8c202c0808494996bccc5d88e8 (diff)
astobj2: assert on invalid ref and backtrace cleanup
If a reference count goes negative, instead of just logging that fact, be more helpful with a backtrace and an assert that will DO_CRASH. This patch also removes the duplicate ao2_bt() function and cleans up extraneous usage of the ast_log_backtrace() call. Review: https://reviewboard.asterisk.org/r/3765/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418963 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/astobj2.c')
-rw-r--r--main/astobj2.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index d2592ecb5..2dd9f0536 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -97,29 +97,6 @@ struct astobj2_rwlock {
struct ao2_stats ao2;
#endif
-#ifdef HAVE_BKTR
-#include <execinfo.h> /* for backtrace */
-#endif
-
-void ao2_bt(void)
-{
-#ifdef HAVE_BKTR
- int depth;
- int idx;
-#define N1 20
- void *addresses[N1];
- char **strings;
-
- depth = backtrace(addresses, N1);
- strings = ast_bt_get_symbols(addresses, depth);
- ast_verbose("backtrace returned: %d\n", depth);
- for (idx = 0; idx < depth; ++idx) {
- ast_verbose("%d: %p %s\n", idx, addresses[idx], strings[idx]);
- }
- ast_std_free(strings);
-#endif
-}
-
#define INTERNAL_OBJ_MUTEX(user_data) \
((struct astobj2_lock *) (((char *) (user_data)) - sizeof(struct astobj2_lock)))
@@ -455,6 +432,9 @@ static int internal_ao2_ref(void *user_data, int delta, const char *file, int li
if (current_value < 0) {
ast_log(__LOG_ERROR, file, line, func,
"Invalid refcount %d on ao2 object %p\n", current_value, user_data);
+ ast_assert(0);
+ /* stop here even if assert doesn't DO_CRASH */
+ return -1;
}
/* last reference, destroy the object */
@@ -516,7 +496,6 @@ int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *fil
}
if (obj == NULL) {
- ast_log_backtrace();
ast_assert(0);
}