delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/07/10:01:42

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <BC46D442BCFB6340A9BB1CED6766E36E3949DF@tons2226>
From: "Willis, Matthew" <Matthew DOT Willis AT CIBC DOT ca>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: 1.3.13 bug with arguments for "ls *" etc. where * is >900 chars
Date: Thu, 7 Nov 2002 09:57:26 -0500
MIME-Version: 1.0

I reported a strange hang with nt4 yesterday and have more information on
how to replicate. Basically, long command line globs seem to cause the
system to get locked up at 100%. The following can replicate

mkdir tmp; cd tmp
for k in 0 1 2 3 4 5 6 7 8 9 a b c d e f
do 
  for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f 
  do 
     touch $j.$k
  done
done

Now, when I do 

ls *                           - this hangs (ctrl-c to get out)
ls [0-9a-f].[0-9a-f]       - this hangs too 
ls [0-9a-e].[0-9a-e]      - but this works fine

It appears related to the absolute length of the arguments rather than the
number of them (above, 225). If I change the inner loop to "touch foo_$j.$k"
then experiment, 

ls foo_*                    - this hangs (256 files)
ls foo_[0-9].[0-9a-b]    - this hangs (120 files)
ls foo_[0-9].[0-9a]      - this works fine (110 files)

It appears that if the arg list is over something like 900 bytes (incl
spaces, e.g. echo [0-9a-e].[0-9a-e] | wc), the program gets confused, which
is consistent with the prior experiment.

I created a small stub program to test if it was something special about
"ls". 

#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char * argv[])
{
  for (int i=0;i<argc; i++) 
    cout << setw(4) << i << " " << argv[i] << endl;
  return 0;
}

This program fails in the same way that ls does. It prints nothing in the
"hanging" cases, and just stops silently. For the okay cases, it prints a
list of args

Is this a bona fide bug? Has it been fixed already? (I am a bit gun shy
about upgrading because I use this machine for production and I got burned
by a compiler update last week.)

My cygcheck.out is attached to a post I made yesterday.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019