From d55bee44179f7dcfebd8eaf1b99730c8473dadea Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 14 Jan 2011 16:01:43 -0800 Subject: [PATCH] Further corrections to the logging layer in runtime. --- src/rt/rust_internal.h | 2 +- src/rt/rust_kernel.cpp | 2 +- src/rt/rust_log.cpp | 8 +++++--- src/rt/rust_task.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index 9a1b2ec001f..61716703deb 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -90,7 +90,7 @@ static intptr_t const CONST_REFCOUNT = 0x7badface; // This accounts for logging buffers. -static size_t const BUF_BYTES = 1024; +static size_t const BUF_BYTES = 2048; // Every reference counted object should derive from this base class. diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 0dc1369dca6..df6b655a45b 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -119,7 +119,7 @@ rust_kernel::is_deadlocked() { void rust_kernel::log(uint32_t type_bits, char const *fmt, ...) { - char buf[256]; + char buf[BUF_BYTES]; if (_log.is_tracing(type_bits)) { va_list args; va_start(args, fmt); diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp index d0ba85de868..bcd40c364b5 100644 --- a/src/rt/rust_log.cpp +++ b/src/rt/rust_log.cpp @@ -114,7 +114,8 @@ append_string(char *buffer, const char *format, ...) { if (buffer != NULL && format) { va_list args; va_start(args, format); - vsprintf(buffer + strlen(buffer), format, args); + size_t off = strlen(buffer); + vsnprintf(buffer + off, BUF_BYTES - off, format, args); va_end(args); } return buffer; @@ -127,7 +128,8 @@ append_string(char *buffer, rust_log::ansi_color color, append_string(buffer, "\x1b%s", _foreground_colors[color]); va_list args; va_start(args, format); - vsprintf(buffer + strlen(buffer), format, args); + size_t off = strlen(buffer); + vsnprintf(buffer + off, BUF_BYTES - off, format, args); va_end(args); append_string(buffer, "\x1b[0m"); } @@ -193,7 +195,7 @@ rust_log::trace_ln(rust_task *task, ansi_color color, uint32_t type_bits, char *message) { if (is_tracing(type_bits)) { if (_use_colors) { - char buffer[512] = ""; + char buffer[BUF_BYTES] = ""; append_string(buffer, color, "%s", message); trace_ln(task, buffer); } else { diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 1522fcccb1c..68882b21882 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -631,7 +631,7 @@ rust_task::get_crate_cache(rust_crate const *curr_crate) void rust_task::log(uint32_t type_bits, char const *fmt, ...) { - char buf[256]; + char buf[BUF_BYTES]; if (dom->get_log().is_tracing(type_bits)) { va_list args; va_start(args, fmt);