From owner-freebsd-bugs@FreeBSD.ORG Tue Jan 23 10:50:27 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6505716A401 for ; Tue, 23 Jan 2007 10:50:27 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 4260013C45E for ; Tue, 23 Jan 2007 10:50:27 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l0NAoIKj042589 for ; Tue, 23 Jan 2007 10:50:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l0NAoIrt042588; Tue, 23 Jan 2007 10:50:18 GMT (envelope-from gnats) Resent-Date: Tue, 23 Jan 2007 10:50:18 GMT Resent-Message-Id: <200701231050.l0NAoIrt042588@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Terry Vernon Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1471616A403 for ; Tue, 23 Jan 2007 10:46:47 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id DCFAA13C4B7 for ; Tue, 23 Jan 2007 10:46:46 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l0NAkkRg079660 for ; Tue, 23 Jan 2007 10:46:46 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l0NAkkhj079655; Tue, 23 Jan 2007 10:46:46 GMT (envelope-from nobody) Message-Id: <200701231046.l0NAkkhj079655@www.freebsd.org> Date: Tue, 23 Jan 2007 10:46:46 GMT From: Terry Vernon To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: bin/108238: the tail command acts weird when reading from a file that's being simultaneously written to X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jan 2007 10:50:27 -0000 >Number: 108238 >Category: bin >Synopsis: the tail command acts weird when reading from a file that's being simultaneously written to >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: Tue Jan 23 10:50:17 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Terry Vernon >Release: 6.2-STABLE >Organization: NerdNOS >Environment: FreeBSD nerdnos 6.2-STABLE FreeBSD 6.2-STABLE #2: Tue Jan 23 00:50:47 CST 2007 root@nerdnos:/usr/obj/usr/src/sys/STREAMLINE i386 >Description: I wrote a simple program in C to make a list of IP style addresses for fun. I wanted to time it piping output to a file and periodically check the file with tail to see how it was coming along. Tail starts acting erratically and eventually latches on to the file being written but is showing incorrect values in the numbers and won't end when you told it to. similar to this: (window 1) time ./ipgen > outfile (window 2) tail -20 outfile The first few times you issue the tail command it does what you would expect but hit your up arrow to repeat the command a few times in succession and you'll see the anomoly. I don't know how or why it does it but thought I'd bring it up in case there's the chance some 0-day security hole could be prepared to exploit it somehow or another. I'll include my make.conf file, and my kernel conf file so you can see how my system is setup, including dmesg.boot output. I've done the make buildworld process using this make.conf file so possibly the optimization flags could play a role but again I'm unsure. [make.conf] CFLAGS=-march=pentium3 -O2 -pipe MAKEOPTS=-j16 CXXFLAGS=${CFLAGS} # added by use.perl 2006-11-22 23:52:34 PERL_VER=5.8.8 PERL_VERSION=5.8.8 [dmesg.boot] Copyright (c) 1992-2007 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 6.2-STABLE #2: Tue Jan 23 00:50:47 CST 2007 root@nerdnos:/usr/obj/usr/src/sys/STREAMLINE MPTable: Timecounter "i8254" frequency 1193182 Hz quality 0 CPU: Pentium III/Pentium III Xeon/Celeron (549.98-MHz 686-class CPU) Origin = "GenuineIntel" Id = 0x673 Stepping = 3 Features=0x383fbff real memory = 2415865856 (2303 MB) avail memory = 2364243968 (2254 MB) FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs cpu0 (BSP): APIC ID: 3 cpu1 (AP): APIC ID: 0 cpu2 (AP): APIC ID: 1 cpu3 (AP): APIC ID: 2 ioapic0: Assuming intbase of 0 ioapic1: Assuming intbase of 24 ioapic1 irqs 24-47 on motherboard ioapic0 irqs 0-23 on motherboard kbd1 at kbdmux0 cpu0 on motherboard cpu1 on motherboard cpu2 on motherboard cpu3 on motherboard pcib0: pcibus 0 on motherboard pci0: on pcib0 isab0: at device 0.0 on pci0 isa0: on isab0 atapci0: port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x450-0x45f at device 0.1 on pci0 ata0: on atapci0 ata1: on atapci0 uhci0: port 0x460-0x47f irq 18 at device 0.2 on pci0 uhci0: [GIANT-LOCKED] usb0: on uhci0 usb0: USB revision 1.0 uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered piix0: port 0x440-0x44f at device 0.3 on pci0 Timecounter "PIIX" frequency 3579545 Hz quality 0 pcib1: at device 1.0 on pci0 pci1: on pcib1 pci1: at device 2.0 (no driver attached) ahc0: port 0x3100-0x31ff mem 0xa7010000-0xa7010fff irq 15 at device 4.0 on pci1 ahc0: [GIANT-LOCKED] aic7895C: Ultra Wide Channel A, SCSI Id=7, 32/253 SCBs ahc1: port 0x3200-0x32ff mem 0xa7011000-0xa7011fff irq 16 at device 4.1 on pci1 ahc1: [GIANT-LOCKED] aic7895C: Ultra Wide Channel B, SCSI Id=7, 32/253 SCBs pci0: at device 10.0 (no driver attached) tx0: port 0x2000-0x20ff mem 0xa78ff000-0xa78fffff irq 34 at device 11.0 on pci0 miibus0: on tx0 qsphy0: on miibus0 qsphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto type SMC9432TX tx0: [GIANT-LOCKED] tx0: Ethernet address: 00:e0:29:3e:d1:3a tx0: if_start running deferred for Giant pcib4: pcibus 4 on motherboard pci4: on pcib4 ips0: port 0x6000-0x60ff mem 0xd3100000-0xd31fffff irq 33 at device 10.0 on pci4 pcib10: pcibus 10 on motherboard pci10: on pcib10 bge0: mem 0xfebf0000-0xfebfffff irq 25 at device 2.0 on pci10 miibus1: on bge0 brgphy0: on miibus1 brgphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX, 1000baseTX-FDX, auto bge0: Ethernet address: 00:02:a5:e7:66:a0 bge1: mem 0xfebe0000-0xfebeffff irq 26 at device 3.0 on pci10 miibus2: on bge1 brgphy1: on miibus2 brgphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX, 1000baseTX-FDX, auto bge1: Ethernet address: 00:02:a5:e7:69:47 pmtimer0 on isa0 orm0: at iomem 0xc0000-0xc7fff,0xc8000-0xc87ff on isa0 atkbdc0: at port 0x60,0x64 on isa0 atkbd0: irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] psm0: irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: model IntelliMouse, device ID 3 ppc0: at port 0x378-0x37f irq 7 on isa0 ppc0: Generic chipset (NIBBLE-only) in COMPATIBLE mode ppbus0: on ppc0 ppi0: on ppbus0 lpt0: on ppbus0 lpt0: Interrupt-driven port sc0: at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0 sio0: type 16550A sio1 at port 0x2f8-0x2ff irq 3 on isa0 sio1: type 16550A vga0: at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 unknown: can't assign resources (port) unknown: can't assign resources (port) unknown: can't assign resources (port) unknown: can't assign resources (irq) unknown: can't assign resources (memory) unknown: can't assign resources (port) Timecounters tick every 1.000 msec ad0: 78167MB at ata0-master UDMA33 Waiting 5 seconds for SCSI devices to settle ips0: reinitializing adapter, this could take several minutes. ips0: adapter type: ServeRAID 3L (clarinet lite) ips0: logical drives: 1 ips0: Logical Drive 0: RAID5 sectors: 35545088, state OK ipsd0: on ips0 ipsd0: Logical Drive (17356MB) SMP: AP CPU #3 Launched! SMP: AP CPU #2 Launched! SMP: AP CPU #1 Launched! Trying to mount root from ufs:/dev/ipsd0s1a [KERNCONF] machine i386 cpu I686_CPU ident STREAMLINE # To statically compile in device wiring instead of /boot/device.hints #hints "GENERIC.hints" # Default places to look for devices. options SCHED_4BSD # scheduler, ULE is slow right now options PREEMPTION # Enable kernel thread preemption options EXT2FS options INET # InterNETworking options INET6 # IPv6 communications protocols options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists options UFS_DIRHASH # Improve performance on big directories options MD_ROOT # MD is a potential root device options NFSCLIENT # Network Filesystem Client options NFSSERVER # Network Filesystem Server options NFS_ROOT # NFS usable as /, requires NFSCLIENT options MSDOSFS # MSDOS Filesystem options CD9660 # ISO 9660 Filesystem options PROCFS # Process filesystem (requires PSEUDOFS) options PSEUDOFS # Pseudo-filesystem framework options GEOM_GPT # GUID Partition Tables. options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!] options COMPAT_FREEBSD4 # Compatible with FreeBSD4 options COMPAT_FREEBSD5 # Compatible with FreeBSD5 options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI options SYSVSHM # SYSV-style shared memory options SYSVMSG # SYSV-style message queues options SYSVSEM # SYSV-style semaphores options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time options KBD_INSTALL_CDEV # install a CDEV entry in /dev options ADAPTIVE_GIANT # Giant mutex is adaptive. device apic # I/O APIC # Bus support. device eisa device pci # ATA and ATAPI devices device ata device atadisk # ATA disk drives device atapicd # ATAPI CDROM drives options ATA_STATIC_ID # Static device numbering # SCSI Controllers device ahc # AHA2940 and onboard AIC7xxx devices device aic # Adaptec 15[012]x SCSI adapters, AIC-6[23]60. # SCSI peripherals device scbus # SCSI bus (required for SCSI) device da # Direct Access (disks) device cd # CD device pass # Passthrough device (direct SCSI access) device ses # SCSI Environmental Services (and SAF-TE) # RAID controllers interfaced to the SCSI subsystem device ips # IBM (Adaptec) ServeRAID # atkbdc0 controls both the keyboard and the PS/2 mouse device atkbdc # AT keyboard controller device atkbd # AT keyboard device psm # PS/2 mouse device kbdmux # keyboard multiplexer device vga # VGA video card driver device splash # Splash screen and screen saver support # syscons is the default console driver, resembling an SCO console device sc device agp # support several AGP chipsets # Power management support (see NOTES for more options) device apm # Add suspend/resume support for the i8254. device pmtimer # Serial (COM) ports device sio # 8250, 16[45]50 based serial ports # Parallel port device ppc device ppbus # Parallel port bus (required) device lpt # Printer device ppi # Parallel port interface device # PCI Ethernet NICs that use the common MII bus controller code. # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! device miibus # MII bus support device bge # Broadcom BCM570xx Gigabit Ethernet device tx # SMC EtherPower II (83c170 ``EPIC'') # Pseudo devices. device loop # Network loopback device random # Entropy device device ether # Ethernet support device sl # Kernel SLIP device ppp # Kernel PPP device tun # Packet tunnel. device pty # Pseudo-ttys (telnet etc) device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device faith # IPv6-to-IPv4 relaying (translation) # The `bpf' device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter # USB support device uhci # UHCI PCI->USB interface device usb # USB Bus (required) options SMP >How-To-Repeat: here's the code to my script that I wrote that helped me see the issue. [ipgen.c]++++++++++++++++++++CUT/PASTE+++++++++++++++++++++++++ #include int main() { int a,b,c,d; a = b = c = d = 0; while (a != 255){ d++; if (d == 255){ c++; d = 0;} if (c == 255){ b++; c = 0;} if (b == 255){ a++; b = 0;} printf("%d.%d.%d.%d\n", a, b, c, d); }return 0;} ++++++++++++++++++++++++CUT/PASTE++++++++++++++++++++++++++++ Compile this with: gcc -march=pentium3 -O2 ipgen.c -o ipgen Then run the program: time ./ipgen > outfile Then try to view 20 lines of output with tail at another console window: tail -20 outfile This is when all the weirdness begins on my system. I'm viewing through an ssh connection from putty on a windows 2k machine over a wifi network. Sometimes it does it on the first try and sometimes it takes up to 6 tries but eventually the numbers aren't right in what the screen shows and the last stage just keeps scrolling as if you had used tail -f. The numbers appear to be earlier in the sequence than where they really are. >Fix: I don't know where to even start. Could be my compiler flags and architecture, could be ssh is somehow omitting the -20 flag for tail by means of network related screwup. >Release-Note: >Audit-Trail: >Unformatted: