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]

Re: Handle leak ?


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


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