diff options
author | George Joseph <gjoseph@digium.com> | 2017-01-25 16:00:49 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-01-25 16:00:49 -0600 |
commit | 9a0b73e339336085e7907836de6eb173207052e2 (patch) | |
tree | bf6c506cca81fe8d06b0672b782289996a3ac00b | |
parent | b21ab3f1cd8cec1277f46a56c4881ac7e608e114 (diff) | |
parent | 930a24a7304d2c7f1a921bd1686cf40774a60307 (diff) |
Merge "astobj2.c: Add excessive ref count trap."
-rw-r--r-- | main/astobj2.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index c8e48bbf5..1529e91b0 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -524,6 +524,20 @@ int __ao2_ref(void *user_data, int delta, if (0 < current_value) { /* The object still lives. */ +#define EXCESSIVE_REF_COUNT 100000 + + if (EXCESSIVE_REF_COUNT <= current_value && ret < EXCESSIVE_REF_COUNT) { + char excessive_ref_buf[100]; + + /* We just reached or went over the excessive ref count trigger */ + snprintf(excessive_ref_buf, sizeof(excessive_ref_buf), + "Excessive refcount %d reached on ao2 object %p", + current_value, user_data); + ast_log(__LOG_ERROR, file, line, func, "%s\n", excessive_ref_buf); + + __ast_assert_failed(0, excessive_ref_buf, file, line, func); + } + if (ref_log && tag) { fprintf(ref_log, "%p,%s%d,%d,%s,%d,%s,%d,%s\n", user_data, (delta < 0 ? "" : "+"), delta, ast_get_tid(), |