AnsweredAssumed Answered

Kernel Panic when destroying the thread in VDK project

Question asked by nigong on Dec 13, 2012
Latest reply on Dec 14, 2012 by CraigG

Hi all,


I am having problem of when the thread finishes its Run() function, it causes Kernel Panic, which the the error code is Unhandled Exception. Value is either 0x21 (Undefined Instruction) or 0x24 (Data Access Misaligned Address Violation). The PC value is either pointing to a NOP operation or a stack operation, making me no where to dig what the real problem is.


The thread function looks like this:

    // TODO - Put the thread's "main" Initialization HERE
          int failureCount;
          output_method_t output_method = UART; 

          failureCount = UnitTest::RunAllTests(true, true, true);
       /*while (1) {


This piece of code would cause kernel panic when the the PC goes to Line 17, which is the exit of the Run function. But we should also be aware of that, the Line 12 code works fine. It did all the things I need it to do and didn't cause any kernel panic.


If I uncomment the forever sleep loop, the whole program works perfectly fine. In other words, if the thread is not killed, there is no kernel panic.


If I comment out the Line 12, then the program would not have kernel panic.


Based on these facts I mentioned above, I think it the Line 12 Code has make the program into a corrupted state and it results in kernel panic when the VDK tries to kill it or when the system calls the destructor to clean the thread.


The RunAllTests() function is a huge function and it is kind of hard to step into. But I also need to know before the VDK kills a thread, what is the correct state it looks like, which means that I can trace what variables and when they got corrupted in RunAllTests() function.


To my knowledge, I can only go this far. I don't know how to go any further and find the root of the problem.


Does anyone have any thoughts?