From f7e07777e033e580351dc6886ab7dbdddd9839fe Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 13 Apr 2008 17:50:45 -0400 Subject: runtime backtrace: stop infinite loops by checking for full print buffer 2008-04-13 Frank Ch. Eigler * print.c (_stp_pbuf_full): New function to note full print buffer. * stack-{i386,x86_64}.c: Use it in all stack-searching loops, to impose another limit against unbounded iteration. --- runtime/print.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'runtime/print.c') diff --git a/runtime/print.c b/runtime/print.c index 0442ba09..4f99be7b 100644 --- a/runtime/print.c +++ b/runtime/print.c @@ -243,6 +243,16 @@ void _stp_print_char (const char c) pb->len ++; } +/** Check whether the print buffer is full. + * @return non-zero if full + */ + +static int _stp_pbuf_full (void) +{ + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); + return (pb->len >= STP_BUFFER_SIZE); +} + /* This function is used when printing maps or stats. */ /* Probably belongs elsewhere, but is here for now. */ -- cgit