[lttng-dev] [PATCH/babeltrace] Fix babeltrace-log crash

Hui Zhu teawater at gmail.com
Fri Sep 7 03:40:14 EDT 2012


Hi,

Got a crash with babeltrace-log.

#0  0x00007ffff744504c in free () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff7ba6fc9 in munmap_align (mma=0x7ffff7ffe620) at
../../../babeltrace/include/babeltrace/mmap-align.h:78
#2  0x00007ffff7ba82db in ctf_packet_seek (stream_pos=0x7fffffffde60,
index=0, whence=0)
    at ../../../babeltrace/formats/ctf/ctf.c:623
#3  0x00007ffff7ba8141 in ctf_init_pos (pos=0x7fffffffde60, fd=8, open_flags=2)
    at ../../../babeltrace/formats/ctf/ctf.c:576
#4  0x0000000000401146 in trace_text (output=8, input=0x7ffff7779340
<_IO_2_1_stdin_>)
    at ../../babeltrace/converter/babeltrace-log.c:233
#5  main (argc=<optimized out>, argv=<optimized out>) at
../../babeltrace/converter/babeltrace-log.c:342

This issue because pos is used before it init.  This patch init it in
function ctf_init_pos.

Thanks,
Hui

--- a/formats/ctf/ctf.c
+++ b/formats/ctf/ctf.c
@@ -550,6 +550,7 @@ error:

 void ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags)
 {
+	memset(pos, 0, sizeof(*pos));
 	pos->fd = fd;
 	if (fd >= 0) {
 		pos->packet_cycles_index = g_array_new(FALSE, TRUE,



More information about the lttng-dev mailing list