The UPDATE_CONTEXT_POINTERS actually breaks lots of debuggers tests. The root probl...
authorZhicheng Zhu <zhizhu@microsoft.com>
Tue, 1 Sep 2015 03:03:00 +0000 (20:03 -0700)
committerZhicheng Zhu <zhizhu@microsoft.com>
Tue, 1 Sep 2015 03:03:00 +0000 (20:03 -0700)
     hr = RtlpUnwindFunctionFull(pContext->Pc - (ULONG)ImageBase,
                                         (ULONG)ImageBase,
                                         &Rfe,
                                         pContext,
                                         &DummyEstablisherFrame,
                                         &DummyHandlerRoutine,
                                         &DummyHandlerData,
                                         NULL);  <-- UnwindParams

     This will set UnwindParams as NULL, and eventually passed to UPDATE_CONTEXT_POINTERS and UPDATE_FP_CONTEXT_POINTERS in RtlpPopRegisterMask. This will generate the AV.
     The fix is just simply checking the whether the Params is NULL or not.

[tfs-changeset: 1520758]

src/unwinder/arm/unwinder_arm.cpp

index f257e1c..8e65ea3 100644 (file)
 #define STATUS_UNWIND_UNSUPPORTED_VERSION   STATUS_UNSUCCESSFUL
 
 
-#define UPDATE_CONTEXT_POINTERS(Params, RegisterNumber, Address)                \
-do {                                                                            \
-    PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers = (Params)->ContextPointers; \
-    if (ARGUMENT_PRESENT(ContextPointers)) {                                    \
-        if (RegisterNumber >=  4 && RegisterNumber <= 11) {                     \
-            (&ContextPointers->R4)[RegisterNumber - 4] = (PULONG)Address;       \
-        } else if (RegisterNumber == 14) {                                      \
-            ContextPointers->Lr = (PULONG)Address;                              \
-        }                                                                       \
-    }                                                                           \
+#define UPDATE_CONTEXT_POINTERS(Params, RegisterNumber, Address)                    \
+do {                                                                                \
+    if (ARGUMENT_PRESENT(Params)) {                                                 \
+        PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers = (Params)->ContextPointers; \
+        if (ARGUMENT_PRESENT(ContextPointers)) {                                    \
+            if (RegisterNumber >=  4 && RegisterNumber <= 11) {                     \
+                (&ContextPointers->R4)[RegisterNumber - 4] = (PULONG)Address;       \
+            } else if (RegisterNumber == 14) {                                      \
+                ContextPointers->Lr = (PULONG)Address;                              \
+            }                                                                       \
+        }                                                                           \
+    }                                                                               \
 } while (0)
 
-#define UPDATE_FP_CONTEXT_POINTERS(Params, RegisterNumber, Address)             \
-do {                                                                            \
-    PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers = (Params)->ContextPointers; \
-    if (ARGUMENT_PRESENT(ContextPointers) &&                                    \
-        (RegisterNumber >=  8) &&                                               \
-        (RegisterNumber <= 15)) {                                               \
-                                                                                \
-        (&ContextPointers->D8)[RegisterNumber - 8] = (PULONGLONG)Address;       \
-    }                                                                           \
+#define UPDATE_FP_CONTEXT_POINTERS(Params, RegisterNumber, Address)                 \
+do {                                                                                \
+    if (ARGUMENT_PRESENT(Params)) {                                                 \
+        PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers = (Params)->ContextPointers; \
+        if (ARGUMENT_PRESENT(ContextPointers) &&                                    \
+            (RegisterNumber >=  8) &&                                               \
+            (RegisterNumber <= 15)) {                                               \
+                                                                                    \
+            (&ContextPointers->D8)[RegisterNumber - 8] = (PULONGLONG)Address;       \
+        }                                                                           \
+    }                                                                               \
 } while (0)
 
 #define VALIDATE_STACK_ADDRESS(Params, Context, DataSize, Alignment, OutStatus)