This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Running getent in a certain way grows it in memory in critical way.


On Feb 26 22:28, Shaddy Baddah wrote:
> I noticed getent on my 64-bit install for the first time today.
> Excited (as I often type it into a Cygwin window, force of habit, to
> no avail), I successfully ran; getent hosts www.google.com.au.
> 
> I then decided to check the usage:
> 
> getent --help
> 
> It printed the first bit of blurb (taken from a Debian system, as I'm
> not about to try this again on Cygwin, but it should be equivalent):
> 
> $ getent --help
> Usage: getent [OPTION...] database [key ...]
> Get entries from administrative database.
> 
>   -i, --no-idn               disable IDN encoding
>   -s, --service=CONFIG       Service configuration to be used
>   -?, --help                 Give this help list
>       --usage                Give a short usage message
>   -V, --version              Print program version
> 
> At this point, there was no more output. Instead the harddrive started
> thrashing and Windows stalled almost to a standstill. Every now and then
> I could get the mouse cursor to move.
> [...]
> Not believing what I had seen, I downloaded the code and checked it. I
> inspected more_help() function, and suspecting the for loop my have
> runaway, I eyed it over. It looks fine to me. I did notice
> open_memstream(), and because I'm not familiar with its usage, I didn't
> give it too much thought. I now think the method of dynamically growing
> memory allocation may be a culprit. But I get ahead of myself.

Hmm, I guess that's my fault.  While porting getent, I found that
the output of `getent --help' was always missing the stuff which
was supposed to be following after the -V,--version:

  Mandatory or optional arguments to long options are also mandatory or optional
  for any corresponding short options.

  Supported databases:
  ahosts ahostsv4 ahostsv6 group hosts initgroups passwd protocols
  services

  For bug reporting instructions, please see:
  http://cygwin.com/problems.html.

In my case it didn't run wild, it just omitted the aforementioned text.
After some debugging it turned out that newlib's open_memstream
functionality had a bug.  It neglected to initialize the variable
containing the current number of bytes written to the mem buffer to 0.
I fixed this bug in newlib, but obviously it's not yet in the released
Cygwin version 1.7.28.  It will be in 1.7.29, though.  So, for the
time being, either refrain from calling `getent --help', or update
to the latest Cygwin snapshot from http://cygwin.com/snapshots/,
which will not have this problem.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgpyHQMgPVIai.pgp
Description: PGP signature


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