Added detection for an obscure bug to let users know I know about it.

This commit is contained in:
Jonas 'Sortie' Termansen 2012-03-18 17:36:31 +01:00
parent d564603460
commit 14a9149f17
1 changed files with 13 additions and 0 deletions

View File

@ -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 )