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:34:54 +0000 (15:34 -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 6acf174655b2b71c16f18eac26c8937d0b2c770c..4e1be1e3d6d3b9dad8fe8e9aa1d720e0c0c1e111 100644 (file)
@@ -863,10 +863,11 @@ void debug_info_handle_event(struct debug_info *debug_info,
                handle_statedump_build_id_event(debug_info, event);
        } else if (event_class->name == debug_info-> q_lib_unload) {
                handle_lib_unload_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;
 }
This page took 0.026137 seconds and 4 git commands to generate.