From nobody@FreeBSD.org  Mon Dec 13 16:06:38 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 64D0E106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Dec 2010 16:06:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id F3A4A8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Dec 2010 16:06:37 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id oBDG6bdM056644
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Dec 2010 16:06:37 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id oBDG6bmk056643;
	Mon, 13 Dec 2010 16:06:37 GMT
	(envelope-from nobody)
Message-Id: <201012131606.oBDG6bmk056643@red.freebsd.org>
Date: Mon, 13 Dec 2010 16:06:37 GMT
From: kenorb <kenorb@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: "grep foo * > somefile" goes into an infinite loop
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         153124
>Category:       bin
>Synopsis:       grep(1): "grep foo * > somefile" goes into an infinite loop
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 13 16:10:09 UTC 2010
>Closed-Date:    
>Last-Modified:  Mon Jan 03 21:10:14 UTC 2011
>Originator:     kenorb
>Release:        8.1-STABLE
>Organization:
>Environment:
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #4: Mon Nov 15 14:40:15 GMT 2010     root@kenorb:/usr/obj/usr/src/sys/BRO  amd64

>Description:
I don't know what's the difference between list.txt and zz.txt, but on zz.txt it always freezing, on list.txt it doesn't;/
It freezing always when you use the name as last file in alphabetical order.
It does work when you grep "table", but doesn't when you grep "td".
>How-To-Repeat:
> perl -e '$i = 1; while($i++ < 5) { system("wget -nc \"http://ai-contest.com/rankings.php?page=$i\""); }'
> grep "td" * > list.txt
# WORKS
> grep "td" * > list.txt
# WORKS
> grep "td" * > zz.txt
# BIG FREEZE UNTIL YOU RUN OF SPACE!
load: 0.66  cmd: grep 39619 [biord] 68.52r 34.09u 15.73s 72% 1156k
load: 0.74  cmd: grep 39619 [running] 78.90r 39.41u 18.58s 80% 1156k
load: 0.96  cmd: grep 39619 [running] 118.59r 60.64u 28.60s 82% 1156k
load: 0.75  cmd: grep 39619 [running] 267.90r 122.22u 62.36s 53% 1156k

39668: read(3,"xt:zz.txt:zz.txt:zz.txt:zz.txt:z"...,24576) = 24576 (0x6000)
39668: write(1,"zz.txt:zz.txt:zz.txt:zz.txt:zz.t"...,16384) = 16384 (0x4000)
39668: read(3,"t:zz.txt:zz.txt:zz.txt:zz.txt:zz"...,24576) = 24576 (0x6000)
39668: write(1,":zz.txt:zz.txt:zz.txt:zz.txt:zz."...,16384) = 16384 (0x4000)
39668: write(1,"z.txt:zz.txt:zz.txt:zz.txt:zz.tx"...,16384) = 16384 (0x4000)
39668: read(3,"z.txt:zz.txt:zz.txt:zz.txt:zz.tx"...,24576) = 24576 (0x6000)
39668: write(1,"txt:zz.txt:zz.txt:zz.txt:zz.txt:"...,16384) = 16384 (0x4000)
39668: read(3,"t:zz.txt:zz.txt:zz.txt:zz.txt:zz"...,24576) = 24576 (0x6000)
39668: write(1,":zz.txt:zz.txt:zz.txt:zz.txt:zz."...,16384) = 16384 (0x4000)
39668: write(1,"z.txt:zz.txt:zz.txt:zz.txt:zz.tx"...,16384) = 16384 (0x4000)
39668: read(3,":zz.txt:zz.txt:zz.txt:zz.txt:zz."...,24576) = 24576 (0x6000)
39668: write(1,".txt:zz.txt:zz.txt:zz.txt:zz.txt"...,16384) = 16384 (0x4000)
39668: read(3,"xt:zz.txt:zz.txt:zz.txt:zz.txt:z"...,24576) = 24576 (0x6000)
39668: write(1,"xt:zz.txt:zz.txt:zz.txt:zz.txt:z"...,16384) = 16384 (0x4000)
>Fix:
Related:
http://savannah.gnu.org/bugs/?17457


>Release-Note:
>Audit-Trail:
>Unformatted:
