public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: "fake" <fake@fake.invalid>
To: <rpj@callisto.canberra.edu.au>, <pthreads-win32@sources.redhat.com>
Subject: Some bugs
Date: Fri, 19 Sep 2003 19:19:00 -0000	[thread overview]
Message-ID: <000501c37ee3$5f24a960$8119fea9@aldebaran> (raw)

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

                 reply	other threads:[~2003-09-19 19:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000501c37ee3$5f24a960$8119fea9@aldebaran' \
    --to=fake@fake.invalid \
    --cc=pthreads-win32@sources.redhat.com \
    --cc=rpj@callisto.canberra.edu.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).