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)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 5 Jun 2019 17:47:34 +0000 (13:47 -0400)
commitc47a6bece6786574f9241c836f98571026dacedf
treed1992414272d45dbc28d615cb2551d571cbd8b56
parent2c67587ab59a15b012008ca38cc13fb77f0eb776
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.024639 seconds and 4 git commands to generate.