Author: sginsberg Date: Mon Mar 26 13:51:15 2012 New Revision: 56235
URL: http://svn.reactos.org/svn/reactos?rev=56235&view=rev Log: [NTOS] - It appears ros wasn't ready for properly handling page faults with interrupts disabled, disable bugcheck and warn and dump stack instead for now. - Make KeRosDumpStackFrameArray and KdbSymPrintAddress safe to use at elavated IRQL -- don't use Unicode formats for DbgPrint at possible elavated IRQL/interrupts disabled as this may generate a page fault. Safely convert to ANSI instead before printing out the address.
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c trunk/reactos/ntoskrnl/ke/bug.c trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/k... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Mon Mar 26 13:51:15 2012 @@ -1130,4 +1130,12 @@ KiRosPcToUserFileHeader(IN PVOID Eip, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry);
+PCHAR +NTAPI +KeBugCheckUnicodeToAnsi( + IN PUNICODE_STRING Unicode, + OUT PCHAR Ansi, + IN ULONG Length +); + #include "ke_x.h"
Modified: trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c... ============================================================================== --- trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] Mon Mar 26 13:51:15 2012 @@ -109,6 +109,30 @@ pLdrEntry); }
+PCHAR +NTAPI +KdbpSymUnicodeToAnsi(IN PUNICODE_STRING Unicode, + OUT PCHAR Ansi, + IN ULONG Length) +{ + PCHAR p; + PWCHAR pw; + ULONG i; + + /* Set length and normalize it */ + i = Unicode->Length / sizeof(WCHAR); + i = min(i, Length - 1); + + /* Set source and destination, and copy */ + pw = Unicode->Buffer; + p = Ansi; + while (i--) *p++ = (CHAR)*pw++; + + /* Null terminate and return */ + *p = ANSI_NULL; + return Ansi; +} + /*! \brief Print address... * * Tries to lookup line number, file name and function name for the given @@ -131,9 +155,14 @@ ULONG LineNumber; CHAR FileName[256]; CHAR FunctionName[256]; + CHAR ModuleNameAnsi[64];
if (!KdbpSymbolsInitialized || !KdbpSymFindModule(Address, NULL, -1, &LdrEntry)) return FALSE; + + KdbpSymUnicodeToAnsi(&LdrEntry->BaseDllName, + ModuleNameAnsi, + sizeof(ModuleNameAnsi));
RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase; Status = KdbSymGetAddressInformation(LdrEntry->PatchInformation, @@ -143,12 +172,12 @@ FunctionName); if (NT_SUCCESS(Status)) { - DbgPrint("<%wZ:%x (%s:%d (%s))>", - &LdrEntry->BaseDllName, RelativeAddress, FileName, LineNumber, FunctionName); + DbgPrint("<%s:%x (%s:%d (%s))>", + ModuleNameAnsi, RelativeAddress, FileName, LineNumber, FunctionName); } else { - DbgPrint("<%wZ:%x>", &LdrEntry->BaseDllName, RelativeAddress); + DbgPrint("<%s:%x>", ModuleNameAnsi, RelativeAddress); }
return TRUE;
Modified: trunk/reactos/ntoskrnl/ke/bug.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=56235... ============================================================================== --- trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] Mon Mar 26 13:51:15 2012 @@ -102,42 +102,6 @@ return PcBase; }
-BOOLEAN -NTAPI -KiRosPrintAddress(PVOID address) -{ - PLIST_ENTRY current_entry; - PLDR_DATA_TABLE_ENTRY current; - extern LIST_ENTRY PsLoadedModuleList; - ULONG_PTR RelativeAddress; - ULONG i = 0; - - do - { - current_entry = PsLoadedModuleList.Flink; - - while (current_entry != &PsLoadedModuleList) - { - current = CONTAINING_RECORD(current_entry, - LDR_DATA_TABLE_ENTRY, - InLoadOrderLinks); - - if (address >= (PVOID)current->DllBase && - address < (PVOID)((ULONG_PTR)current->DllBase + - current->SizeOfImage)) - { - RelativeAddress = (ULONG_PTR)address - - (ULONG_PTR)current->DllBase; - DbgPrint("<%wZ: %x>", ¤t->FullDllName, RelativeAddress); - return(TRUE); - } - current_entry = current_entry->Flink; - } - } while(++i <= 1); - - return(FALSE); -} - PVOID NTAPI KiRosPcToUserFileHeader(IN PVOID Pc, @@ -270,9 +234,14 @@ if (!KdbSymPrintAddress((PVOID)Addr, NULL)) #endif { - /* Print out the module name */ + CHAR AnsiName[64]; + + /* Convert module name to ANSI and print it */ + KeBugCheckUnicodeToAnsi(&LdrEntry->BaseDllName, + AnsiName, + sizeof(AnsiName)); Addr -= (ULONG_PTR)LdrEntry->DllBase; - DbgPrint("<%wZ: %p>", &LdrEntry->FullDllName, (PVOID)Addr); + DbgPrint("<%s: %p>", AnsiName, (PVOID)Addr); } } else
Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.c... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Mon Mar 26 13:51:15 2012 @@ -1190,6 +1190,7 @@ /* Enable interupts */ _enable();
+#if 0 /* Check if we faulted with interrupts disabled */ if (!(TrapFrame->EFlags & EFLAGS_INTERRUPT_MASK)) { @@ -1201,6 +1202,14 @@ TrapFrame->Eip, TrapFrame); } +#else + if (!(TrapFrame->EFlags & EFLAGS_INTERRUPT_MASK)) + { + /* Warn and dump stack */ + DPRINT1("Page fault with interrupts disabled!\n"); + KeRosDumpStackFrames(NULL, 0); + } +#endif
/* Check for S-LIST fault in kernel mode */ if (TrapFrame->Eip == (ULONG_PTR)ExpInterlockedPopEntrySListFault)