From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Possiblly bug of cygwin1.dll
Date: Wed, 24 Jan 2024 14:11:38 +0100 [thread overview]
Message-ID: <ZbEMiot8xnlKPj47@calimero.vinschen.de> (raw)
In-Reply-To: <ZbELFu6Ly4U9UBZo@calimero.vinschen.de>
On Jan 24 14:05, Corinna Vinschen via Cygwin wrote:
> On Jan 24 20:55, Takashi Yano via Cygwin wrote:
> > On Mon, 22 Jan 2024 19:24:52 -0800
> > Kaz Kylheku wrote:
> > > In real systems, the static distinction has no meaning.
> > >
> > > This code can be inside a shared library:
> > >
> > > static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
> > >
> > > this library could be loaded by dlopen and unloaded with dlclose.
> > > Thus static becomes dynamic!
> > >
> > > And, by the way, this is a problem: if we have a library
> > > which does the above, and we repeatedly load it and unload
> > > it while using the mutex in between, it will leak.
> >
> > As you pointed out, if dlopen()/dlclose() are called repeatedly,
> > handle leak might occur even if pthread_mutex_t is statically
> > allocated.
>
> Cygwin 3.5 is due really soon now, so we can't change anything here,
> except fixing the pthread_once problem (@takashi, didn't you want to
> apply your patch?)
>
> As for the next major release, do we have a chance to revamp
> pthread_mutex_t so that it does NOT dynamically create an OS synch
> object? Is there a way we can change the really much too complex
> pthreads code to simplify things and use, say, SRWLOCKs, or any other
> synch mechanism which is faster and less intrusive?
>
> The biggest problem, IMHO, is the DREADED fact that the original author
> of the pthreads code defined the exposed pthread types as, for instance,
>
> typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t;
>
> So they only take 1 byte in user space and there's no chance to fit
> an SRWLOCK or, FWIW, a LONG value in there to be used with Interlocked
> functions. That's really a problem we're kind of stuck with, I fear.
No, wait, I'm an idiot. The types are defined as *pointers*, so
they have a size of 8 bytes in user code. That means we should
be able to implement this differently, less dynamic, and still
be able to do it backward compatible.
We *really should try that and simplifying things at the same time.
Is anybody willing to give this a whirl? We have a good year until
the next major release...
Corinna
next prev parent reply other threads:[~2024-01-24 13:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 13:44 Takashi Yano
2024-01-19 14:28 ` Corinna Vinschen
2024-01-20 4:18 ` Takashi Yano
2024-01-20 5:13 ` Takashi Yano
2024-01-20 9:13 ` ASSI
2024-01-20 12:24 ` Takashi Yano
2024-01-20 12:46 ` ASSI
2024-01-21 11:10 ` Takashi Yano
2024-01-21 13:30 ` ASSI
2024-01-22 3:30 ` Takashi Yano
2024-01-22 9:25 ` Corinna Vinschen
2024-01-22 9:57 ` Corinna Vinschen
2024-01-22 11:16 ` Takashi Yano
2024-01-22 11:49 ` Corinna Vinschen
2024-01-22 12:41 ` ASSI
2024-01-22 14:54 ` Corinna Vinschen
2024-01-22 11:06 ` Takashi Yano
2024-01-22 11:42 ` Corinna Vinschen
2024-01-23 3:24 ` Kaz Kylheku
2024-01-24 11:55 ` Takashi Yano
2024-01-24 13:05 ` Corinna Vinschen
2024-01-24 13:11 ` Corinna Vinschen [this message]
2024-01-24 20:37 ` Kaz Kylheku
2024-01-24 20:08 ` Kaz Kylheku
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=ZbEMiot8xnlKPj47@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
/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).