Fix: Double free when calling bt_context_remove_trace()
authorJérémie Galarneau <>
Mon, 21 Jan 2013 21:22:01 +0000 (16:22 -0500)
committerMathieu Desnoyers <>
Wed, 23 Jan 2013 14:40:26 +0000 (09:40 -0500)
ctf_close_trace was being called twice when calling
bt_context_remove_trace thus causing free() to be called on an invalid

Calling bt_context_remove_trace() would call ctf_close_trace() once via
the close_handle callback registered on the ctf format struct and a
second call would take place from bt_trace_handle_destroy() which is
registered as the value_destroy_func on the trace_handles hash table of
the current context.

bt_trace_handle_destroy() now only deallocates the trace handle and does
not perform the trace closing. This makes the
bt_trace_handle_create/destroy and bt_context_add/remove_trace parts of
the public API symmetric.

The crash is reproducible by invoking the script.

Signed-off-by: Jérémie Galarneau <>
Signed-off-by: Mathieu Desnoyers <>

index 0da565b02000e230eb9322dbc34bc3dffe5c0f5e..455e4407e37722be78f18ed5311cf0af7c7b5430 100644 (file)
@@ -49,7 +49,6 @@ struct bt_trace_handle *bt_trace_handle_create(struct bt_context *ctx)
 void bt_trace_handle_destroy(struct bt_trace_handle *th)
-       th->format->close_trace(th->td);
This page took 0.024123 seconds and 4 git commands to generate.