This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Some bugs


I've found a couple of bugs in pthread-win32. I can't tell you the exact
source files/lines 'cause my job requires me not to look at the sources, and
I found the bugs during the reverse-engineerign of your official binaries
(hey, just doin' my job). Anyway:
 - sched_setscheduler: you never CloseHnalde tyhe handle obtained through
OpenProcess:

  push    esi
  mov     esi, [esp+pid]
  test    esi, esi
  jz      short loc_10005795
  call    ds:GetCurrentProcessId
  cmp     esi, eax
  jz      short loc_10005795
  push    esi             ; dwProcessId
  push    0               ; bInheritHandle
  push    PROCESS_SET_INFORMATION ; dwDesiredAccess
  call    ds:OpenProcess
  test    eax, eax
  jnz     short loc_10005795 ; <<< leak!!
  call    ds:GetLastError
  mov     esi, eax
  sub     esi, 5
  neg     esi
  sbb     esi, esi
  and     esi, 2
  inc     esi
  call    ds:_errno
  mov     [eax], esi
  or      eax, -1
  pop     esi
  retn ;
; -------------------------------------------------------------

loc_10005795:
  mov     eax, [esp+policy]
  test    eax, eax
  jz      short loc_100057AE
  call    ds:_errno
  mov     dword ptr [eax], 40 ; ENOSYS
  or      eax, -1         ; failure
  pop     esi
  retn
; -------------------------------------------------------------

loc_100057AE:
  xor     eax, eax        ; success
  pop     esi
  retn

 - you seem to be declaring all functions __declspec(dllimport) even for the
build of the dll itself. This generates kinda weird binaries, with all
functions residing at the lowest offsets of .text and containing just jmps
to hugher addresses in the segment. The M$ linker generatse a warning about
it ("local name 'XXX' imported", or something like that), and you shouldn't
ignore it. Nothing ciritcal, but it just doesn't look right


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]