Fix : segfault when printing timestamp on index
authorJulien Desfossez <julien.desfossez@efficios.com>
Tue, 21 Feb 2012 21:47:15 +0000 (16:47 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 21:47:15 +0000 (16:47 -0500)
If we detect we lost events in a packet, we print an error message
containing the begin and end timestamps of the packet.  If we detect
this packet loss while generating the index (during the open_trace), the
trace_collection is not yet referenced and so the clock information is
not available. This fix prevents the printing at this stage.

Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c

index 83680cd697f764e23969a19ae86df8763e8bc508..fa19648155964faa6a8dbedc283a2fbb2d655ab2 100644 (file)
@@ -535,16 +535,25 @@ void ctf_packet_seek(struct stream_pos *stream_pos, size_t index, int whence)
                         * be printed in the output.
                         */
                        if (file_stream->parent.events_discarded) {
                         * be printed in the output.
                         */
                        if (file_stream->parent.events_discarded) {
-                               fflush(stdout);
-                               fprintf(stderr, "[warning] Tracer discarded %d events at end of stream between [",
-                                       file_stream->parent.events_discarded);
-                               ctf_print_timestamp(stderr, &file_stream->parent,
-                                       file_stream->parent.prev_timestamp);
-                               fprintf(stderr, "] and [");
-                               ctf_print_timestamp(stderr, &file_stream->parent,
-                                       file_stream->parent.prev_timestamp_end);
-                               fprintf(stderr, "]. You should consider increasing the buffer size.\n");
-                               fflush(stderr);
+                               /*
+                                * We need to check if we are in trace
+                                * read or called from packet indexing.
+                                * In this last case, the collection is
+                                * not there, so we cannot print the
+                                * timestamps.
+                                */
+                               if ((&file_stream->parent)->stream_class->trace->collection) {
+                                       fflush(stdout);
+                                       fprintf(stderr, "[warning] Tracer discarded %d events at end of stream between [",
+                                                       file_stream->parent.events_discarded);
+                                       ctf_print_timestamp(stderr, &file_stream->parent,
+                                                       file_stream->parent.prev_timestamp);
+                                       fprintf(stderr, "] and [");
+                                       ctf_print_timestamp(stderr, &file_stream->parent,
+                                                       file_stream->parent.prev_timestamp_end);
+                                       fprintf(stderr, "]. You should consider increasing the buffer size.\n");
+                                       fflush(stderr);
+                               }
                                file_stream->parent.events_discarded = 0;
                        }
                        pos->offset = EOF;
                                file_stream->parent.events_discarded = 0;
                        }
                        pos->offset = EOF;
This page took 0.024989 seconds and 4 git commands to generate.