Fix: lib: prevent infinite recursion when destroying trace classes and traces
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 8 May 2019 21:07:22 +0000 (17:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 13 Jun 2019 21:24:21 +0000 (17:24 -0400)
commit69868f440d14cc5065b66cf1e89ee9e14843281e
tree754d94a3db758fe3a9fe22fdf459e989f906e332
parent824ce8b67717c0384a85adcd4e556dbd3de2ce48
Fix: lib: prevent infinite recursion when destroying trace classes and traces

When implementing support for trace and trace class destruction
listeners in Python, we hit a problem where we enter infinite recursion
(until the process crashes).

When the refcount of a trace class reaches 0, the destruction listeners
for that trace class are called.  The Python listener creates a
TraceClass object, which acquires a new reference to the trace class
being destroyed.  When the listener is done, it drops that reference.
This causes the refcount to reach 0 again, and the lib to call all the
destruction listeners again.

The same happens for traces.

To prevent it, this patch makes the lib increment the refcount by one
before calling all destruction listeners.

Change-Id: Ib7e7bd0428c2a505fb25ad0aa80150b518da4c4e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1282
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
lib/trace-ir/trace-class.c
lib/trace-ir/trace.c
This page took 0.026747 seconds and 4 git commands to generate.