From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [lttng-dev] [PATCH babletrace 1.3/1.4] Fix: segmentation fault with multi-trace having non-correlated clocks
Date: Thu, 19 May 2016 16:32:45 -0400 [thread overview]
Message-ID: <1463689965-5185-1-git-send-email-mathieu.desnoyers@efficios.com> (raw)
This bugfix is extracted from commit
commit 61cf588beae752e5ddfc60b6b5310f769ac9e852
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Tue Feb 9 13:27:24 2016 -0500
Handle negative time and offset from Epoch
Which was fixing this issue, amongst other things.
[ This fix should be applied to Babeltrace stable 1.3 and 1.4 only. ]
Fixes: #790
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
lib/context.c | 72 ++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 49 insertions(+), 23 deletions(-)
diff --git a/lib/context.c b/lib/context.c
index 45aab34..7774ccd 100644
--- a/lib/context.c
+++ b/lib/context.c
@@ -115,7 +115,7 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
fprintf(stderr, "[error] [Context] Creating trace handle %s .\n\n",
path);
ret = -1;
- goto error;
+ goto error_close;
}
handle->format = fmt;
handle->td = td;
@@ -124,41 +124,67 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
handle->path[PATH_MAX - 1] = '\0';
}
+ ret = bt_trace_collection_add(ctx->tc, td);
+ if (ret != 0)
+ goto error_destroy_handle;
+
if (fmt->set_handle)
fmt->set_handle(td, handle);
if (fmt->set_context)
fmt->set_context(td, ctx);
- /* Add new handle to container */
- g_hash_table_insert(ctx->trace_handles,
- (gpointer) (unsigned long) handle->id,
- handle);
- ret = bt_trace_collection_add(ctx->tc, td);
- if (ret != 0)
- goto error;
-
if (fmt->convert_index_timestamp) {
ret = fmt->convert_index_timestamp(td);
if (ret < 0)
- goto error;
+ goto error_collection_del;
+ }
+
+ if (fmt->timestamp_begin) {
+ handle->real_timestamp_begin =
+ fmt->timestamp_begin(td, handle, BT_CLOCK_REAL);
+ if (handle->real_timestamp_begin == -1ULL) {
+ ret = -1;
+ goto error_collection_del;
+ }
+ }
+ if (fmt->timestamp_end) {
+ handle->real_timestamp_end =
+ fmt->timestamp_end(td, handle, BT_CLOCK_REAL);
+ if (handle->real_timestamp_end == -1ULL) {
+ ret = -1;
+ goto error_collection_del;
+ }
+ }
+ if (fmt->timestamp_begin) {
+ handle->cycles_timestamp_begin =
+ fmt->timestamp_begin(td, handle, BT_CLOCK_CYCLES);
+ if (handle->cycles_timestamp_begin == -1ULL) {
+ ret = -1;
+ goto error_collection_del;
+ }
+ }
+ if (fmt->timestamp_end) {
+ handle->cycles_timestamp_end =
+ fmt->timestamp_end(td, handle, BT_CLOCK_CYCLES);
+ if (handle->cycles_timestamp_end == -1ULL) {
+ ret = -1;
+ goto error_collection_del;
+ }
}
- if (fmt->timestamp_begin)
- handle->real_timestamp_begin = fmt->timestamp_begin(td,
- handle, BT_CLOCK_REAL);
- if (fmt->timestamp_end)
- handle->real_timestamp_end = fmt->timestamp_end(td, handle,
- BT_CLOCK_REAL);
- if (fmt->timestamp_begin)
- handle->cycles_timestamp_begin = fmt->timestamp_begin(td,
- handle, BT_CLOCK_CYCLES);
- if (fmt->timestamp_end)
- handle->cycles_timestamp_end = fmt->timestamp_end(td, handle,
- BT_CLOCK_CYCLES);
+ /* Add new handle to container */
+ g_hash_table_insert(ctx->trace_handles,
+ (gpointer) (unsigned long) handle->id,
+ handle);
return handle->id;
-error:
+error_collection_del:
+ /* Remove from containers */
+ bt_trace_collection_remove(handle->td->ctx->tc, handle->td);
+error_destroy_handle:
+ bt_trace_handle_destroy(handle);
+error_close:
closeret = fmt->close_trace(td);
if (closeret) {
fprintf(stderr, "Error in close_trace callback\n");
--
2.1.4
reply other threads:[~2016-05-19 20:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463689965-5185-1-git-send-email-mathieu.desnoyers@efficios.com \
--to=mathieu.desnoyers@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox