diff options
author | Jan Kotas <jkotas@microsoft.com> | 2015-02-28 09:02:26 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2015-02-28 09:02:26 -0800 |
commit | cedb628adc86100b44afce570e45f25a0e34943a (patch) | |
tree | c52881f6e284e1f6c60a8355ab30f78512140574 | |
parent | dc69f3054732ae2eba459a4828727e1f9d6b5d13 (diff) | |
download | coreclr-cedb628adc86100b44afce570e45f25a0e34943a.tar.gz coreclr-cedb628adc86100b44afce570e45f25a0e34943a.tar.bz2 coreclr-cedb628adc86100b44afce570e45f25a0e34943a.zip |
Filter out faked save locations returned by libunwind
-rw-r--r-- | src/pal/src/exception/seh-unwind.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp index 0b3a51187a..98c7f0b5c2 100644 --- a/src/pal/src/exception/seh-unwind.cpp +++ b/src/pal/src/exception/seh-unwind.cpp @@ -88,7 +88,7 @@ static void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) #endif } -static void GetContextPointer(unw_cursor_t *cursor, int reg, PDWORD64 *contextPointer) +static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, int reg, PDWORD64 *contextPointer) { #if defined(__APPLE__) //OSXTODO @@ -97,20 +97,23 @@ static void GetContextPointer(unw_cursor_t *cursor, int reg, PDWORD64 *contextPo unw_get_save_loc(cursor, reg, &saveLoc); if (saveLoc.type == UNW_SLT_MEMORY) { - *contextPointer = (PDWORD64)saveLoc.u.addr; + PDWORD64 pLoc = (PDWORD64)saveLoc.u.addr; + // Filter out fake save locations that point to unwContext + if ((pLoc < (PDWORD64)unwContext) || ((PDWORD64)(unwContext + 1) <= pLoc)) + *contextPointer = (PDWORD64)saveLoc.u.addr; } #endif } -static void GetContextPointers(unw_cursor_t *cursor, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) +static void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) { #if defined(_AMD64_) - GetContextPointer(cursor, UNW_X86_64_RBP, &contextPointers->Rbp); - GetContextPointer(cursor, UNW_X86_64_RBX, &contextPointers->Rbx); - GetContextPointer(cursor, UNW_X86_64_R12, &contextPointers->R12); - GetContextPointer(cursor, UNW_X86_64_R13, &contextPointers->R13); - GetContextPointer(cursor, UNW_X86_64_R14, &contextPointers->R14); - GetContextPointer(cursor, UNW_X86_64_R15, &contextPointers->R15); + GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, &contextPointers->Rbp); + GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, &contextPointers->Rbx); + GetContextPointer(cursor, unwContext, UNW_X86_64_R12, &contextPointers->R12); + GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13); + GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14); + GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15); #else #error unsupported architecture #endif @@ -154,7 +157,7 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP if (contextPointers != NULL) { - GetContextPointers(&cursor, contextPointers); + GetContextPointers(&cursor, &unwContext, contextPointers); } return TRUE; |