Hi,
currently the free handle entry list is a lifo list. This is not a good solution for process and thread ids because a id from a currently deleted process or thread is valid again after a very short time. I would like it to change the free list to a fifo list by using a double linked list. The u2 part of an entry has enough room for a list entry instead an index.
- Hartmut
Hartmut Birr wrote:
Hi,
currently the free handle entry list is a lifo list. This is not a good solution for process and thread ids because a id from a currently deleted process or thread is valid again after a very short time. I would like it to change the free list to a fifo list by using a double linked list. The u2 part of an entry has enough room for a list entry instead an index.
Please don't, the executive handle table structures are public and shouldn't be changed. Plus, the fifo list is index based, which means there don't have to be special operations when duplicating/inheriting a handle table, they can be copied without recalculation or anything. I'm going to mark CIDs as invalid for a certain time instead of deletion, which should fix the issues.
Best Regards, Thomas
Hartmut Birr wrote:
Hi,
currently the free handle entry list is a lifo list. This is not a good solution for process and thread ids because a id from a currently deleted process or thread is valid again after a very short time. I would like it to change the free list to a fifo list by using a double linked list. The u2 part of an entry has enough room for a list entry instead an index.
Actually, win 2000 uses a lifo list, you can see this by compiling and running the attached code. Each time a thread is created and terminated it receives the same client id. win xp however seems to mark client ids as invalid for a certain amount of time or uses a fifo list, I haven't investigated further though, the test code however displays different client ids in XP.
Since win2000 does it the same way, I think we shouldn't worry too much. We however could add some debugging stuff where deleted client id handles are not destroyed but marked as invalid to track down wrong code easier.
Best Regards, Thomas
#include <windows.h> #include <stdio.h>
DWORD WINAPI ThrdProc(LPVOID lpParameter) { return 0; }
int main(int argc, char* argv[]) { for(;;) { DWORD tid;
HANDLE hThread = CreateThread(NULL, 0, ThrdProc, NULL, 0, &tid); if(hThread != NULL) { printf("tid: %d\n", (int)tid); WaitForSingleObject(hThread, INFINITE); CloseHandle(hThread); } else { printf("CreateThread failed!\n"); return 0; } }
return(0); }