From 14a9149f17d05f57c74edc41992d5e15f5bd8188 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 18 Mar 2012 17:36:31 +0100 Subject: [PATCH] Added detection for an obscure bug to let users know I know about it. --- sortix/vgaterminal.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sortix/vgaterminal.cpp b/sortix/vgaterminal.cpp index f0334ecc..f2b18908 100644 --- a/sortix/vgaterminal.cpp +++ b/sortix/vgaterminal.cpp @@ -149,6 +149,19 @@ namespace Sortix // display the text. size_t Print(void* /*user*/, const char* string, size_t stringlen) { + // Check for the bug where string contains the address 0x80000000 + // which is not legal to print. It looks like we are trying to + // print a string from the stack that wasn't NUL-terminated. I + // tracked down the string value comes from LogTerminal, but it + // doesn't seem to originate from a write(2) call. Weird stuff. + addr_t straddr = (addr_t) string; + if ( straddr <= 0x80000000UL && 0x80000000UL <= straddr + stringlen ) + { + PanicF("Trying to print bad string 0x%zx + 0x%zx bytes: this " + "is a known bug, but with an unknown cause.", straddr, + stringlen); + } + // Iterate over each character. size_t left = stringlen; while ( (left--) > 0 )