On Fri, 27 May 2005, Eric Faurot wrote:

> I've noted that jot(1) behaviour is erratic on my system (ibook) wrt to
> random number generation.

Ik can reproduce this on my G3 iBook, but not on my Mac mini. 

It turns out that x becomes suddenly 0 after some iterations of this loop:

                for (i = 1; i <= reps || infinity; i++) {
                        double v;
                        y = arc4random() / ((double)0xffffffff + 1);
                        v = y * x + begin;
                        if (putdata(v, reps == i && !infinity))
                                errx(1, "range error in conversion: %f", v); 
                }

Making x a global var makes the problem disappear. My guess is that we are 
looking at either a code generation problem or a fp context save/restore 
problem.

Will dig into this a bit deeper later.

        -Otto

> 
> "jot -r 0" will start generating 1's continuously after a (short) while.
> It does it even quicker when higher precision is requested.
> "jot -p 9 0" starts throwing 1.000000000's after 74 random lines.
> "jot -p 5 0" will do that after 104 lines.  Oddly enough, it happens
> only when output goes to the terminal (pipes and redirections seem to
> work).
> 
> Also, the examples in the manpage produce very suspicious results: The
> following happens every 4 or 5 invocations:
> 
> $ jot -r -p 0 100000 0.5 3.5 | sort -n | uniq -c 
> 33162 1
> 33422 2
> 33416 3
> $ jot -r -p 0 100000 0.5 3.5 | sort -n | uniq -c 
> 33183 1
> 33223 2
> 33594 3
> $ jot -r -p 0 100000 0.5 3.5 | sort -n | uniq -c 
>  838 1
>  781 2
>  784 3
> 97597 0
> 
> 
> Another one (more than half the time):
> 
> $ jot -w %d -r 100000 1 4 | sort -n | uniq -c 
> 33104 1
> 33476 2
> 33420 3
> $ jot -w %d -r 100000 1 4 | sort -n | uniq -c 
> 89731 1
> 5164 2
> 5105 3
> $ jot -w %d -r 100000 1 4 | sort -n | uniq -c 
> 33210 1
> 33443 2
> 33347 3
> $ jot -w %d -r 100000 1 4 | sort -n | uniq -c 
> 97808 1
> 1090 2
> 1102 3
> 
> I'm not an entropy expert, but I suspect there is something very wrong.
> All seem to work fine on i386.  So I guess it is a macppc issue.
> Here is the dmesg output.
> 
> [ using 308668 bytes of bsd ELF symbol table ]
> console out [ATY,Bee_A]console in [keyboard] ADB found
> using parent ATY,BeeParent:: memaddr 98000000 size 8000000, : consaddr
> 9c008000, : ioaddr 90020000, size 20000: memtag 8000, iotag 8000:
> width 1024 linebytes 1024 height 768 depth 8
> Copyright (c) 1982, 1986, 1989, 1991, 1993
>       The Regents of the University of California.  All rights reserved.
> Copyright (c) 1995-2005 OpenBSD. All rights reserved.  http://www.OpenBSD.org
> 
> OpenBSD 3.7 (GENERIC) #225: Sun Mar 20 00:55:39 MST 2005
>     [EMAIL PROTECTED]:/usr/src/sys/arch/macppc/compile/GENERIC
> real mem = 134217728 (131072K)
> avail mem = 112680960 (110040K)
> using 1254 buffers containing 6709248 bytes of memory
> mainbus0 (root)
> cpu0 at mainbus0: 750FX (Revision 0x203): 800 MHz: 512KB L2 cache
> memc0 at mainbus0: uni-n
> mpcpcibr0 at mainbus0: uni-north, Revision 0xff
> pci0 at mpcpcibr0 bus 0
> pchb0 at pci0 dev 11 function 0 "Apple Pangea AGP" rev 0x00
> vgafb0 at pci0 dev 16 function 0 "ATI Radeon Mobility M7 LW" rev 0x00, mmio
> wsdisplay0 at vgafb0: console (std, vt100 emulation)
> mpcpcibr1 at mainbus0: uni-north, Revision 0x0
> pci1 at mpcpcibr1 bus 0
> pchb1 at pci1 dev 11 function 0 "Apple Pangea PCI" rev 0x00
> macobio0 at pci1 dev 23 function 0 "Apple Pangea" rev 0x00
> openpic0 at macobio0: version 0x4614
> gpio_obio0 at macobio0
> gpio_obio1 at gpio_obio0 offset 0x9 irq 47
> programmer-switch at gpio_obio0 offset 0x11 not configured
> firewire-linkon at gpio_obio0 offset 0x5b not configured
> cpu-vcore-select at gpio_obio0 offset 0x6b not configured
> extint-gpio4 at gpio_obio0 offset 0x5c not configured
> gpio9 at gpio_obio0 offset 0x73 not configured
> extint-gpio12 at gpio_obio0 offset 0x64 not configured
> gpio5 at gpio_obio0 offset 0x6f not configured
> gpio6 at gpio_obio0 offset 0x70 not configured
> extint-gpio4 at gpio_obio0 offset 0x5c not configured
> gpio11 at gpio_obio0 offset 0x75 not configured
> extint-gpio15 at gpio_obio0 offset 0x67 not configured
> zsc0 at macobio0: irq 22,23
> zstty0 at zsc0 channel 0
> zstty1 at zsc0 channel 1
> snapper0 at macobio0: irq 30,1,2
> adb0 at macobio0 irq 25: via-pmu 3 targets
> aed0 at adb0 addr 0: ADB Event device
> akbd0 at adb0 addr 2: iBook keyboard with inverted T (ISO layout)
> wskbd0 at akbd0 (mux 1 ignored for console): console keyboard, using 
> wsdisplay0
> ams0 at adb0 addr 3: EMP trackpad <tpad> 2-button, 400 dpi
> wsmouse0 at ams0 mux 0
> abtn0 at adb0 addr 7: brightness/volume/eject buttons
> apm0 at adb0: battery flags 0x5, 0% charged
> ki2c0 at macobio0
> wdc0 at macobio0 irq 19: DMA
> wd0 at wdc0 channel 0 drive 0: <FUJITSU MHS2030AT>
> wd0: 16-sector PIO, LBA48, 28615MB, 58605120 sectors
> atapiscsi0 at wdc0 channel 0 drive 1
> scsibus0 at atapiscsi0: 2 targets
> cd0 at scsibus0 targ 0 lun 0: <QSI, CD-ROM SCR-242, CL18> SCSI0
> 5/cdrom removable
> wd0(wdc0:0:0): using PIO mode 4, DMA mode 2
> cd0(wdc0:0:1): using PIO mode 4, DMA mode 2
> audio0 at snapper0
> ohci0 at pci1 dev 24 function 0 "Apple Pangea USB" rev 0x00: irq 27, version 
> 1.0
> usb0 at ohci0: USB revision 1.0
> uhub0 at usb0
> uhub0: Apple OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
> uhub0: 2 ports with 2 removable, self powered
> ohci1 at pci1 dev 25 function 0 "Apple Pangea USB" rev 0x00: irq 28, version 
> 1.0
> usb1 at ohci1: USB revision 1.0
> uhub1 at usb1
> uhub1: Apple OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
> uhub1: 2 ports with 2 removable, self powered
> mpcpcibr2 at mainbus0: uni-north, Revision 0x6
> pci2 at mpcpcibr2 bus 0
> pchb2 at pci2 dev 11 function 0 "Apple Pangea PCI" rev 0x00
> "Apple Pangea FireWire" rev 0x00 at pci2 dev 14 function 0 not configured
> gem0 at pci2 dev 15 function 0 "Apple GMAC" rev 0x00: irq 41, address
> 00:0a:95:89:b1:9c
> bmtphy0 at gem0 phy 0: BCM5221 100baseTX PHY, rev. 4
> uhidev0 at uhub1 port 1 configuration 1 interface 0
> uhidev0: Logitech USB Mouse, rev 1.10/6.20, addr 2, iclass 3/1
> ums0 at uhidev0: 3 buttons and Z dir.
> wsmouse1 at ums0 mux 0
> bootpath: '/[EMAIL PROTECTED]/[EMAIL PROTECTED]/[EMAIL PROTECTED]/[EMAIL 
> PROTECTED]/bsd'
> boot device: wd0.
> root on wd0a
> rootdev=0x0 rrootdev=0xb00 rawdev=0xb02
> ugen0 at uhub1 port 2
> ugen0: HCF USB V.90 Data/Fax Modem Apple internal modem, rev 1.10/1.00, addr 3

Reply via email to