ntdll:exception crashes some Windows 10

Francois Gouget fgouget at codeweavers.com
Tue Dec 8 11:10:52 CST 2020


On Tue, 8 Dec 2020, Paul Gofman wrote:
[...]
> Are you commenting out here in the cited code or (better) in dreg_handler?

I did the commenting in the cited code. I tried again in dreg_handler() 
and that shows I can set Dr6 and Dr1 but none of the others (which makes 
sense I guess).

Here's what I tested in patch form to avoid ambiguity:

commit f54d113590d1de43ec3ef6ff78369b9dc9d1bdb6
Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Dec 8 17:58:39 2020 +0100

    HACK ntdll:exception: Comment out most tests to avoid a crash.
    
    * Uncommenting any of the C++ lines causes the
      KERNEL_SECURITY_CHECK_FAILURE crash.
    * All if (0) except one just skip irrelevant tests.
    * The second dreg_handler test produces the same crashes. Ignore it
      until the first one is fixed / diagnosed.
    
    Signed-off-by: Francois Gouget <fgouget at codeweavers.com>

diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index 5686e39ab9e..cd078d662c1 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -776,12 +776,12 @@ static DWORD dreg_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD
     const struct dbgreg_test *test = *(const struct dbgreg_test **)(frame + 1);
 
     context->Eip += 2;	/* Skips the popl (%eax) */
-    context->Dr0 = test->dr0;
+    //context->Dr0 = test->dr0;
     context->Dr1 = test->dr1;
-    context->Dr2 = test->dr2;
-    context->Dr3 = test->dr3;
+    //context->Dr2 = test->dr2;
+    //context->Dr3 = test->dr3;
     context->Dr6 = test->dr6;
-    context->Dr7 = test->dr7;
+    //context->Dr7 = test->dr7;
     return ExceptionContinueExecution;
 }
 
@@ -989,13 +989,16 @@ static void test_exceptions(void)
     run_exception_test(dreg_handler, &dreg_test, &segfault_code, sizeof(segfault_code), 0);
     check_debug_registers(1, &dreg_test);
 
+    if (0) { /* causes crashes too but ignore for now */
     dreg_test.dr0 = 0x42424242;
     dreg_test.dr2 = 0x100f0fe7;
     dreg_test.dr3 = 0x0abebabe;
     dreg_test.dr7 = 0x115;
     run_exception_test(dreg_handler, &dreg_test, &segfault_code, sizeof(segfault_code), 0);
     check_debug_registers(2, &dreg_test);
+    }
 
+    if (0) {
     /* test single stepping behavior */
     got_exception = 0;
     run_exception_test(single_step_handler, NULL, &single_stepcode, sizeof(single_stepcode), 0);
@@ -1052,6 +1055,7 @@ static void test_exceptions(void)
     ctx.Dr7 = 0;
     res = pNtSetContextThread( GetCurrentThread(), &ctx );
     ok( res == STATUS_SUCCESS, "NtSetContextThread failed with %x\n", res );
+    }
 }
 
 static void test_debugger(void)
@@ -8189,8 +8193,11 @@ START_TEST(exception)
 
 #ifdef __i386__
 
+  if (0) {
     test_unwind();
+  }
     test_exceptions();
+  if (0) {
     test_rtlraiseexception();
     test_debug_registers();
     test_debug_service(1);
@@ -8201,6 +8208,7 @@ START_TEST(exception)
     test_kiuserexceptiondispatcher();
     test_extended_context();
     test_copy_context();
+  }
 
 #elif defined(__x86_64__)
 
@@ -8248,6 +8256,7 @@ START_TEST(exception)
 
 #endif
 
+  if (0) {
     test_debugger();
     test_thread_context();
     test_outputdebugstring(1, FALSE);
@@ -8264,5 +8273,6 @@ START_TEST(exception)
     test_suspend_thread();
     test_suspend_process();
     test_unload_trace();
+  }
     VirtualFree(code_mem, 0, MEM_RELEASE);
 }


-- 
Francois Gouget <fgouget at codeweavers.com>



More information about the wine-devel mailing list