About the dll search algorithm of dlopen (patch-r3)

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Aug 26 10:59:00 GMT 2016

Hi Michael,

On Aug 25 19:48, Michael Haubenwallner wrote:
> Using tmp_pathbuf now, wrapped behind some trivial allocator - which
> might fit better somewhere else than to dlfcn.cc?
> BTW: Is it really intended for tmp_pathbuf to have a single active
> instance (per thread) at a time?

Well, yes.  tmp_pathbuf is meant to be initialized on function entry
(more or less, depends).  It's supposed to exist only once per frame.
When the frame goes out of scope, the tmp_pathbuf usage counter is
restored to the values of the parent frame.

> +   ATTENTION: Requesting memory from an instance of tmp_pathbuf breaks
> +   when another instance on a newer stack frame has provided memory. */

I don't understand this comment, though.  tmp_pathbuf can be used
multiple times in the same thread stackm see other Cygwin functions.
What you can't do is to call a function, instantiate tmp_pathbuf,
allocate memory in the called function, and then use it in the caller.
Well, you *can* do that, but if you do this more than once, the same
memory region is reused.
That's the whole idea of tmp_pathbuf.
Temporary per-thread memory for the current frame and it's child frames
is allocated.  If a deeper frame using tmp_pathbuf goes out of scope,
the memory is not free'd, but recycled next time temporary memory is
needed.  The buffers are either 32K or 64K to matches the maximum long
path length.  They are now used for any purpose where larger temporary
per-thread memory is needed, but providing temporary long path buffers
without killing the stack was their original purposes.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20160826/8d5b849f/attachment.sig>

More information about the Cygwin-developers mailing list