debug info: Call register_event_debug_infos for all events
authorSimon Marchi <simon.marchi@polymtl.ca>
Sun, 19 Jun 2016 15:14:29 +0000 (11:14 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 25 Jul 2016 19:36:11 +0000 (15:36 -0400)
The register_event_debug_infos function is responsible for setting the
debug_info_src field of the struct definition_integer representing the
"ip" context field.  This pointer is used later to print the
source and binary location of the tracepoint.

Currently, it's not called for the events that have a special meaning
for the debug info analysis (statedump start, dlopen, bin_info, etc).
This means that for these events, the debug_info_src pointer keeps the
value of the previous event from that stream (since the ip field is in
stream event context, there is one instance per stream), which leads to
wrong information and/or crash.  A crash can happen when the debug info
structures are cleared because a statedump start is encountered.
debug_info_src becomes a stale pointer and babeltrace tries to print a
string in free memory.

The fix is to call register_event_debug_infos for all events, which will
always set debug_info_src properly.  The events used to do the debug
info analysis are still regular events and have their own location
information.

The trace in bug #1018 shows a crash caused by this issue.

Here's an example of wrong info from the same trace:

... lttng_ust_statedump:bin_info: { cpu_id = 1 }, { vpid = 28991, ip = 0x7FD26665657D, debug_info = { bin = "libX11.so.6.3.0+0x213fa" } }, ...
... lttng_ust_statedump:build_id: { cpu_id = 1 }, { vpid = 28991, ip = 0x7FD266656656, debug_info = { bin = "libX11.so.6.3.0+0x213fa" } }, ...

We can see that the ip values are different, but the debug info refers
to the same location, which is impossible.  Here's the result with this
patch applied.

... lttng_ust_statedump:bin_info: { cpu_id = 1 }, { vpid = 28991, ip = 0x7FD26665657D, debug_info = { bin = "liblttng-ust.so.0.0.0+0x3557d", func = "trace_bin_info_cb+0xfa" } }, ...
... lttng_ust_statedump:build_id: { cpu_id = 1 }, { vpid = 28991, ip = 0x7FD266656656, debug_info = { bin = "liblttng-ust.so.0.0.0+0x35656", func = "trace_build_id_cb+0xbc" } }, ...

which seems more reasonnable.

Fixed #1018

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/debug-info.c

index cfb47f6381af0cfcf0e41dc897a07b77b52e13a9..ff9af79c02cac9d031c1907c024cbe473c806ff4 100644 (file)
@@ -795,11 +795,11 @@ void debug_info_handle_event(struct debug_info *debug_info,
        } else if (event_class->name == debug_info->q_statedump_build_id) {
                /* Build ID info */
                handle_statedump_build_id_event(debug_info, event);
        } else if (event_class->name == debug_info->q_statedump_build_id) {
                /* Build ID info */
                handle_statedump_build_id_event(debug_info, event);
-       } else {
-               /* Other events: register debug infos */
-               register_event_debug_infos(debug_info, event);
        }
 
        }
 
+       /* All events: register debug infos */
+       register_event_debug_infos(debug_info, event);
+
 end:
        return;
 }
 end:
        return;
 }
This page took 0.025434 seconds and 4 git commands to generate.