Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1643 Improper alignment in SYSTEM_THREAD/PROCESS_INFORMATION

WSL
pending
Earnie Boyd
None
Bug
later
Feature_in_WSL_4.1
False
2013-02-19
2012-06-13
Anton Lavrentiev
No

Hi,
Structures declared in win32api to get NtQuerySystemInformation() for SystemProcessInformation miss proper alignments, and so do not work correctly,
Namely, these two structures suffer (correct field layout shown):

/* CYGWIN defines these two stucts incorrectly (missing some alignment) */
typedef struct _SYSTEM_THREAD {
LARGE_INTEGER KernelTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER CreateTime;
DWORD WaitTime;
PVOID StartAddress;
DWORD ProcessId;
DWORD ThreadId;
KPRIORITY Priority;
KPRIORITY BasePriority;
ULONG ContextSwitchCount;
THREAD_STATE State; /* state: active (<5), waiting (5) */
KWAIT_REASON WaitReason; /* waiting reason (5 = suspended) */
DWORD Reserved1; /* missing in CYGWIN, aling to quad */
} SYSTEM_THREAD;
typedef struct _SYSTEM_PROCESS_INFORMATION {
ULONG NextEntryOffset;
ULONG ThreadCount;
ULONG Reserved1[6];
LARGE_INTEGER CreateTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER KernelTime;
UNICODE_STRING ProcessName;
KPRIORITY BasePriority;
DWORD ProcessId;
DWORD InheritedFromProcessId;
ULONG HandleCount;
DWORD Reserved2[2];
VM_COUNTERS VmCounters; /* NB: *not* quad aligned! */
ULONG PrivatePageCount; /* CYGWIN bug, quad align for prev */
IO_COUNTERS IoCounters;
SYSTEM_THREAD Threads[1];
} SYSTEM_PROCESS_INFORMATION;

Please fix!

Thanks,
Anton Lavrentiev

Discussion

  • Earnie Boyd
    Earnie Boyd
    2012-06-14

    • assigned_to: nobody --> ir0nh34d
     
  • Earnie Boyd
    Earnie Boyd
    2012-08-05

    I must be blind. Exactly what files contain these?

     
  • Earnie Boyd
    Earnie Boyd
    2012-08-05

    • milestone: --> 519164
    • assigned_to: ir0nh34d --> earnie
    • status: open --> pending
     
    • status: pending --> open
     
  • Sorry, must have missed your question. The structures are defined in /usr/include/w32api/ddk/ntapi.h .

     
  • Earnie Boyd
    Earnie Boyd
    2012-08-30

    • status: open --> pending
     
  • Earnie Boyd
    Earnie Boyd
    2012-08-30

    I don't find these in w32api/ddk/ntapi.h. I find something similar with SYSTEM_THREADS (note the S indicating plural) and SYSTEM_PROCESSES but not SYSTEM_PROCESS_INFORMATION. But why would Cygwin's installed version be different?

     
  • You are actually correct -- the names I used for the similar-named structures, I took "as is" from my source code, because I could not use ntapi.h-provided names (would have been in conflict of redefinition). So in the above, my SYSTEM_THREAD corresponds to what mingw's SYSTEMS_THREADS should have been, and my SYSTEM_PROCESS_INFORMATION corresponds to what mingw's SYSTEM_PROCESSES should have been defined (BTW, MS does use SYSTEM_PROCESS_INFORMATION for the latter in their documentation, although with fields mostly opaque).

     
  • Earnie Boyd
    Earnie Boyd
    2012-08-30

    Thanks for the clarification. I've set the reminder flag for me to look at this at a later date.

     
  • Earnie Boyd
    Earnie Boyd
    2012-08-30

    • milestone: 519164 --> Known_bugs
    • status: pending --> open-remind
     
  • Earnie Boyd
    Earnie Boyd
    2012-10-30

    • labels: 103945 --> WSL (Windows System Libraries)
    • status: open-remind --> pending-remind
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-04

    • labels: WSL (Windows System Libraries) -->
    • status: pending-remind --> pending
    • resolution: --> later
    • category: --> Known_bugs
    • milestone: Known_bugs --> WSL
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-11

    • type: --> Bug
    • patch_attached: --> False
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-19

    • category: Known_bugs --> Feature_in_WSL_4.1