[Asterisk-code-review] astobj2.c: Add excessive ref count trap. (asterisk[13])

George Joseph asteriskteam at digium.com
Thu Jan 26 07:35:43 CST 2017


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/4801 )

Change subject: astobj2.c: Add excessive ref count trap.
......................................................................


astobj2.c: Add excessive ref count trap.

Change-Id: I32e6a589cf9009450e4ff7cb85c07c9d9ef7fe4a
---
M main/astobj2.c
1 file changed, 13 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Matthew Fredrickson: Looks good to me, approved



diff --git a/main/astobj2.c b/main/astobj2.c
index 7320c5e..569db0b 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -421,6 +421,19 @@
 
 	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);
+		}
 		return ret;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/4801
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I32e6a589cf9009450e4ff7cb85c07c9d9ef7fe4a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>



More information about the asterisk-code-review mailing list