Hi,
in KeRundownThread is an ASSERT statement. What is the reason for that? ApcDisable is never changed. It is always 1 for mutex objects and always 0 for mutant objects. If a mutant object is on the list, ros does crash.
- Hartmut
Index: ntoskrnl/ke/kthread.c =================================================================== --- ntoskrnl/ke/kthread.c (revision 14297) +++ ntoskrnl/ke/kthread.c (working copy) @@ -360,7 +360,7 @@
/* Get the Mutant */ Mutant = CONTAINING_RECORD(CurrentEntry, KMUTANT, MutantListEntry); - ASSERT(Mutant->ApcDisable); +// ASSERT(Mutant->ApcDisable);
Hartmut Birr wrote:
Hi,
in KeRundownThread is an ASSERT statement. What is the reason for that? ApcDisable is never changed. It is always 1 for mutex objects and always 0 for mutant objects. If a mutant object is on the list, ros does crash.
- Hartmut
Index: ntoskrnl/ke/kthread.c
--- ntoskrnl/ke/kthread.c (revision 14297) +++ ntoskrnl/ke/kthread.c (working copy) @@ -360,7 +360,7 @@
/* Get the Mutant */ Mutant = CONTAINING_RECORD(CurrentEntry, KMUTANT, MutantListEntry);
ASSERT(Mutant->ApcDisable);+// ASSERT(Mutant->ApcDisable);
It should actually be a bugcheck with THREAD_TERMINATE_HELD_MUTEX, but I only discovered this weird Bugcode much later after coding this. See some information here:
http://groups-beta.google.com/group/comp.os.ms-windows.nt.misc/browse_frm/th...
here:
/ // MessageId: *THREAD_TERMINATE_HELD_MUTEX* // // MessageText: // // A kernel thread terminated while holding a mutex //
Best regards, Alex Ionescu
Alex Ionescu wrote:
It should actually be a bugcheck with THREAD_TERMINATE_HELD_MUTEX, but I only discovered this weird Bugcode much later after coding this. See some information here:
http://groups-beta.google.com/group/comp.os.ms-windows.nt.misc/browse_frm/th...
here:
/ // MessageId: *THREAD_TERMINATE_HELD_MUTEX* // // MessageText: // // A kernel thread terminated while holding a mutex //
Best regards, Alex Ionescu
Exist there a way to check, if the mutex is only used in user mode? A user mode thread can create and lock a mutex. An other thread terminates this thraed and ros does crash.
- Hartmut
Hartmut Birr wrote:
Alex Ionescu wrote:
How can a user-mode thread create a mutex?
Simply with CreateMutex.
CreateMutex creates a Mutant....
I change the assert statement to:
ASSERT(Mutant->Header.Size == sizeof(KMUTANT)/sizeof(ULONG));
This does ros crash only for mutex objects and not for mutant objects.
That's what the assert should do as well. Mutants have APC Disable = 0. Mutexes have it =1. Usermode can only create mutant, so apcdisable will always be 0.
I don't understand how user-mode can create a mutex?
- Hartmut
Best regards, Alex Ionescu
Alex Ionescu wrote:
That's what the assert should do as well. Mutants have APC Disable = 0. Mutexes have it =1. Usermode can only create mutant, so apcdisable will always be 0.
This means the ASSERT statemant is wrong. The correct statement is:
ASSERT(Mutant->ApcDisable == 0);
- Hartmut
Hartmut Birr wrote:
Alex Ionescu wrote:
That's what the assert should do as well. Mutants have APC Disable = 0. Mutexes have it =1. Usermode can only create mutant, so apcdisable will always be 0.
This means the ASSERT statemant is wrong. The correct statement is:
ASSERT(Mutant->ApcDisable == 0);
- Hartmut
Hi,
Right, sorry for not seeing this! Can you please fix it, my kthread.c is completely modified due to my local scheduler rewrite. Thank you!
Best regards, Alex Ionescu