Use trace->trace_id in check to remove trace from bt_ctx
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 3 Jul 2018 16:28:54 +0000 (12:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 Jul 2018 19:21:38 +0000 (15:21 -0400)
Commit b9e6498df8b3e7c2ad312dccddf9f1a5e181648e removes the existence
guarantee of the trace_id hash table key by moving the trace->in_use
assignation before the assignation of trace_id and insertion into the
hash table.

Use the trade_id field value to validate if it should be removed from
the hash table. A NULL trace_id field indicates that no insertion was
performed.

This is mostly a workaround to a problem found in, at least, glib 2.28
where g_hash_table_lookup_node() aborts on a SIGFPE signal due to
modulo by zero. The exact cause for this is unknown for now, but a
similar problem was reported against Nautilus [1].

There is little reason for "mod" to be 0 at that point, as explained
in the bug report.

Currently unable to reproduce.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1074401

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/lttng-live/lttng-live-comm.c
formats/lttng-live/lttng-live.h

index 055b1c30e5b321981d3e1fa3072429d545cae8b6..ec03fb2fc410eeb849f52977dff86276cb9a6b68 100644 (file)
@@ -390,6 +390,7 @@ int lttng_live_ctf_trace_assign(struct lttng_live_viewer_stream *stream,
        if (!trace) {
                trace = g_new0(struct lttng_live_ctf_trace, 1);
                trace->ctf_trace_id = ctf_trace_id;
+               trace->trace_id = -1;
                printf_verbose("Create trace ctf_trace_id %" PRIu64 "\n", ctf_trace_id);
                BT_INIT_LIST_HEAD(&trace->stream_list);
                g_hash_table_insert(stream->session->ctf_traces,
@@ -1466,7 +1467,7 @@ int del_traces(gpointer key, gpointer value, gpointer user_data)
                lvstream->in_trace = 0;
                bt_list_del(&lvstream->trace_stream_node);
        }
-       if (trace->in_use) {
+       if (trace->in_use && trace->trace_id >= 0) {
                ret = bt_context_remove_trace(bt_ctx, trace->trace_id);
                if (ret < 0)
                        fprintf(stderr, "[error] removing trace from context\n");
index 9739078a52e67278ca3b9d85962700e9a317cfc1..34c57edee6343bd15ee8e125699ad73a9ab96780 100644 (file)
@@ -88,6 +88,7 @@ struct lttng_live_ctf_trace {
        struct bt_list_head stream_list;
        FILE *metadata_fp;
        struct bt_trace_handle *handle;
+       /* Set to -1 when not initialized. */
        int trace_id;
        int in_use;
 };
This page took 0.025455 seconds and 4 git commands to generate.