From: Simon Marchi Date: Sun, 19 Jun 2016 15:14:29 +0000 (-0400) Subject: debug info: Call register_event_debug_infos for all events X-Git-Tag: v1.5.0-rc1~20 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=09c9a6e8d4ece8431f4fd305efac21ea054ccc97 debug info: Call register_event_debug_infos for all events 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 Signed-off-by: Jérémie Galarneau --- diff --git a/lib/debug-info.c b/lib/debug-info.c index cfb47f63..ff9af79c 100644 --- a/lib/debug-info.c +++ b/lib/debug-info.c @@ -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 { - /* 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; }