ref.c: warn when the ref count goes from 0 to 18446744073709551615
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 May 2017 22:21:48 +0000 (18:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:44 +0000 (12:57 -0400)
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 <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/ref.c

index 153146af4622484e2c6437220c364012d36fb37e..02d2c4e9bf914fe3467600d81ea4d5abd13058d9 100644 (file)
--- 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,
This page took 0.026844 seconds and 4 git commands to generate.