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)
commit09c9a6e8d4ece8431f4fd305efac21ea054ccc97
tree946da130d3738be19bdbd1bb640a3835c186d063
parent09b40be3e9ef3d34cf0618332a027235cfa4fece
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 <simon.marchi@polymtl.ca>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/debug-info.c
This page took 0.024618 seconds and 4 git commands to generate.