From: Philippe Proulx Date: Wed, 24 May 2017 22:21:48 +0000 (-0400) Subject: ref.c: warn when the ref count goes from 0 to 18446744073709551615 X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=aa04c1b62de23763a267d97f51b1c31be170d11a;p=deliverable%2Fbabeltrace.git ref.c: warn when the ref count goes from 0 to 18446744073709551615 This unlikely conditin indicates a double bt_put(), or something that went really wrong, and should be reported to the user as a warning. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/lib/ref.c b/lib/ref.c index 153146af4..02d2c4e9b 100644 --- a/lib/ref.c +++ b/lib/ref.c @@ -70,6 +70,11 @@ void bt_put(void *ptr) return; } + if (BT_LOG_ON_WARN && unlikely(bt_object_get_ref_count(obj) == 0)) { + BT_LOGW("Decrementing a reference count set to 0: addr=%p", + ptr); + } + BT_LOGV("Decrementing object's reference count: %lu -> %lu: " "addr=%p, cur-count=%lu, new-count=%lu", obj->ref_count.count, obj->ref_count.count - 1,