public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* Handle leak ?
@ 2000-07-20  3:18 Paul Redondo
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Redondo @ 2000-07-20  3:18 UTC (permalink / raw)
  To: ML Pthreads-Win32

Hi there.

Did anybody noticed a huge handle leak when creating lots of detached
threads ?
I've been creating lots of detached threads during 24 hours, and the NT Task
Manager shows me an incredible amount of opened handles. Ok, my code may be
wrong ;-P But, it may not.

So, anybody else encountered this problem ?

C.U.
--
Paul Redondo - paul@matchvision.com - +33 6 16300303 / +33 6 16309014
MatchVision's R&D Team - http://www.matchvision.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Handle leak ?
  2000-07-20  3:28 Steve Croall
@ 2000-07-20 16:56 ` David Baggett
  0 siblings, 0 replies; 3+ messages in thread
From: David Baggett @ 2000-07-20 16:56 UTC (permalink / raw)
  To: 'Paul Redondo', ML Pthreads-Win32

Yup, I spent two weeks trying to track this down.

There's a bug in the current code (unless it has been fixed in the last
month or so) that causes not only the handle leakage you're seeing,
but alsoinfrequent crashes. The relevant code is in dll.c:

/*
 * Detached threads have their resources automatically
 * cleaned up upon exit (others must be 'joined'
 */
if (self != NULL && self->detachState == PTHREAD_CREATE_DETACHED) {
    if (self->threadH) {
        pthread_setspecific (_pthread_selfThreadKey, NULL);
        _pthread_threadDestroy (self);
    }
}

If you don't have the "if (self->threadH)" guard (which I've added
here), you'll see handle leakage and very low frequency crashes.
I reported this to this list some time ago but didn't get much response,
so I doubt the distribution has been updated to fix this.

I was not able to track down the bug that this guard prevents.
In other words, I could not figure out why it was getting to that
point in the code with self->threadH equaling zero. I only found this
by spending a long time putting assertions throughout the code.

Running full bore for 24 hours, you'll still see a very tiny amount
of handle leakage even with this workaround. I don't know what
causes that, but it won't be a problem in practice. (You have to
create enormous numbers of threads to even detect it.)

Dave

> -----Original Message-----
> From: Paul Redondo [ mailto:paul@matchvision.com ]
> Sent: 20 July 2000 11:16
> To: ML Pthreads-Win32
> Subject: Handle leak ?
>
>
> Hi there.
>
> Did anybody noticed a huge handle leak when creating lots of detached
> threads ?
> I've been creating lots of detached threads during 24 hours, and the NT
Task
> Manager shows me an incredible amount of opened handles. Ok, my code may
be
> wrong ;-P But, it may not.
>
> So, anybody else encountered this problem ?
>
> C.U.
> --
> Paul Redondo - paul@matchvision.com - +33 6 16300303 / +33 6 16309014
> MatchVision's R&D Team - http://www.matchvision.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Handle leak ?
@ 2000-07-20  3:28 Steve Croall
  2000-07-20 16:56 ` David Baggett
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Croall @ 2000-07-20  3:28 UTC (permalink / raw)
  To: 'Paul Redondo', ML Pthreads-Win32

Paul,

Do you "join"/"detach" to/from the thread after creating it?  If not the
resources used by the thread are not cleared up.

Look at pthread_join() and pthread_detach() MAN pages.

Steve.

-----Original Message-----
From: Paul Redondo [ mailto:paul@matchvision.com ]
Sent: 20 July 2000 11:16
To: ML Pthreads-Win32
Subject: Handle leak ?


Hi there.

Did anybody noticed a huge handle leak when creating lots of detached
threads ?
I've been creating lots of detached threads during 24 hours, and the NT Task
Manager shows me an incredible amount of opened handles. Ok, my code may be
wrong ;-P But, it may not.

So, anybody else encountered this problem ?

C.U.
--
Paul Redondo - paul@matchvision.com - +33 6 16300303 / +33 6 16309014
MatchVision's R&D Team - http://www.matchvision.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-07-20 16:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-20  3:18 Handle leak ? Paul Redondo
2000-07-20  3:28 Steve Croall
2000-07-20 16:56 ` David Baggett

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).