From: Josef Bacik <jbacik@fb.com>
To: <rostedt@goodmis.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] trace-cmd: make sure we have a pending pid in trace-hist
Date: Fri, 8 Aug 2014 16:26:17 -0400 [thread overview]
Message-ID: <1407529577-15548-1-git-send-email-jbacik@fb.com> (raw)
I have a trace.dat file where we lost some events and so we didn't have the
corresponding event to go with the stack trace. This made trace-cmd hist
segfault because it unconditionally pushes the pending_pid's function onto the
stack trace. In this case pending_pid < 0, which means we didn't have a pending
stack trace, so we got garbage in the call chain and hilarity ensued. Fix this
by only pushing the pending call chain if there actually is one, and also don't
reset the current call chain if there isn't actually one there either. This
fixed my segfault. Thanks,
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
trace-hist.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/trace-hist.c b/trace-hist.c
index 73820de..574549e 100644
--- a/trace-hist.c
+++ b/trace-hist.c
@@ -453,9 +453,11 @@ process_kernel_stack(struct pevent *pevent, struct pevent_record *record)
}
} else {
/* function stack trace? */
- copy_stack_to_pending(current_pid);
- free(ips);
- reset_stack();
+ if (current_pid >= 0) {
+ copy_stack_to_pending(current_pid);
+ free(ips);
+ reset_stack();
+ }
}
current_pid = pid;
@@ -482,8 +484,10 @@ process_kernel_stack(struct pevent *pevent, struct pevent_record *record)
push_stack_func(func);
}
- push_stack_func(pending_ips[pending_ips_idx - 1]);
- reset_pending_stack();
+ if (pending_pid >= 0) {
+ push_stack_func(pending_ips[pending_ips_idx - 1]);
+ reset_pending_stack();
+ }
save_call_chain(current_pid, ips, ips_idx, 1);
if (do_restore)
restore_stack(current_pid);
--
2.0.0
next reply other threads:[~2014-08-08 20:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-08 20:26 Josef Bacik [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-07-30 20:54 Josef Bacik
2014-08-08 19:33 ` Steven Rostedt
2014-08-08 19:34 ` Josef Bacik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407529577-15548-1-git-send-email-jbacik@fb.com \
--to=jbacik@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®