I wrote a trivial program to fill vm and found I can reliably freeze my
system. It may not work on the first attempt, but certainly within three.
My command line is:


The goal of my program is simply to see how the system behaves under
memory exhaustion which, as it turns out on two similar systems, the
systems freeze. Specifically, I can switch between consoles but the login
prompts do not respond and the system does not respond on the network.

I am running 4.3 on a dual processor system.

Below are some things. First, the program. Second, dmesg. Finally, my


#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

main( void ) {

        int     rd = open( "/dev/random", O_RDONLY );
        char*   mem = 0;
        int     cnt = 0;

        if( rd < 0 ) {

                fprintf( stderr, "unable to open random device\n" );
                exit( 1 );

        while( mem = malloc( 1024 )) {

                int i, j, k;

                for( i = 1024, j = 0; i > 0; ) {

                        while(( j = read( rd, mem + ( 1024 - i ), i )) <= 0 )
                        i =- j;

                if(( ++cnt % 1024 ) == 0 ) {

                        putchar( '.' );
                        fflush( stdout );

                if(( cnt % ( 10 * 1024 )) == 0 ) {

                        system( "/bin/sync" );
                        sleep( 2 );


        putchar( '\n' );

        return 0;

Copyright (c) 1992-2001 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 4.3-STABLE #6: Wed May  2 19:57:42 PDT 2001
Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium III/Pentium III Xeon/Celeron (860.89-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x686  Stepping = 6
real memory  = 268034048 (261752K bytes)
avail memory = 254472192 (248508K bytes)
Changing APIC ID for IO APIC #0 from 0 to 2 on chip
Programming 24 pins in IOAPIC #0
IOAPIC #0 intpin 2 -> irq 0
FreeBSD/SMP: Multiprocessor motherboard
 cpu0 (BSP): apic id:  0, version: 0x00040011, at 0xfee00000
 cpu1 (AP):  apic id:  1, version: 0x00040011, at 0xfee00000
 io0 (APIC): apic id:  2, version: 0x00170020, at 0xfec00000
Preloaded elf kernel "kernel" at 0xc049e000.
Pentium Pro MTRR support enabled
md0: Malloc disk
npx0: <math processor> on motherboard
npx0: INT 16 interface
pcib0: <Host to PCI bridge> on motherboard
IOAPIC #0 intpin 19 -> irq 2
IOAPIC #0 intpin 17 -> irq 13
pci0: <PCI bus> on pcib0
pcib1: <PCI to PCI bridge (vendor=8086 device=250f)> at device 1.0 on pci0
pci1: <PCI bus> on pcib1
pci1: <NVidia Riva TNT2 graphics accelerator> at 0.0 irq 16
pcib2: <Intel 82801AA (ICH) Hub to PCI bridge> at device 30.0 on pci0
IOAPIC #0 intpin 18 -> irq 17
pci2: <PCI bus> on pcib2
pci2: <unknown card> (vendor=0x1102, dev=0x0002) at 7.0 irq 16
pci2: <unknown card> (vendor=0x1102, dev=0x7002) at 7.1
ahc0: <Adaptec 29160N Ultra160 SCSI adapter> port 0xe800-0xe8ff mem 
0xfafff000-0xfaffffff irq 13 at device 8.0 on pci2
aic7892: Wide Channel A, SCSI Id=7, 32/255 SCBs
xl0: <3Com 3c905-TX Fast Etherlink XL> port 0xec80-0xecbf irq 16 at device 11.0 on pci2
xl0: Ethernet address: 00:60:08:b0:3d:a6
miibus0: <MII bus> on xl0
nsphy0: <DP83840 10/100 media interface> on miibus0
nsphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
xl1: <3Com 3c905C-TX Fast Etherlink XL> port 0xec00-0xec7f mem 0xfaffec00-0xfaffec7f 
irq 17 at device 12.0 on pci2
xl1: Ethernet address: 00:b0:d0:a2:62:ac
miibus1: <MII bus> on xl1
xlphy0: <3c905C 10/100 internal PHY> on miibus1
xlphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
isab0: <Intel 82801AA (ICH) PCI to LPC bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel ICH ATA66 controller> port 0xffa0-0xffaf at device 31.1 on pci0
ata1: at 0x170 irq 15 on atapci0
uhci0: <Intel 82801AA (ICH) USB controller> port 0xff80-0xff9f irq 2 at device 31.2 on 
usb0: <Intel 82801AA (ICH) USB controller> 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
ums0: Microsoft Microsoft Wheel Mouse Optical\M-., rev 1.10/1.21, addr 2, iclass 3/1
ums0: 3 buttons and Z dir.
pci0: <unknown card> (vendor=0x8086, dev=0x2413) at 31.3 irq 13
fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
sc0: <System console> 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
ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode
ppc0: FIFO with 16/16/8 bytes threshold
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
ppi0: <Parallel I/O> on ppbus0
APIC_IO: Testing 8254 interrupt delivery
APIC_IO: routing 8254 via IOAPIC #0 intpin 2
IP packet filtering initialized, divert enabled, rule-based forwarding enabled, 
default to deny, logging limited to 512 packets/entry by default
IPsec: Initialized Security Association Processing.
IP Filter: v3.4.16 initialized.  Default = pass all, Logging = enabled
SMP: AP CPU #1 Launched!
acd0: CDROM <Lite-On LTN483S 48x Max> at ata1-master using PIO4
Waiting 2 seconds for SCSI devices to settle
Mounting root from ufs:/dev/da0s1a
da0 at ahc0 bus 0 target 0 lun 0
da0: <QUANTUM ATLAS10K2-TY092L DA40> Fixed Direct Access SCSI-3 device
da0: 160.000MB/s transfers (80.000MHz, offset 127, 16bit), Tagged Queueing Enabled
da0: 8683MB (17783239 512 byte sectors: 255H 63S/T 1106C)
da1 at ahc0 bus 0 target 1 lun 0
da1: <SEAGATE ST318451LW 0003> Fixed Direct Access SCSI-3 device
da1: 160.000MB/s transfers (80.000MHz, offset 63, 16bit), Tagged Queueing Enabled
da1: 17501MB (35843671 512 byte sectors: 255H 63S/T 2231C)
WARNING: / was not properly dismounted
xl0: promiscuous mode enabled

# This file now contains just the overrides from /etc/defaults/rc.conf
# please make all changes to this file.
rand_irqs="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
ntpdate_flags="-b tick.usnogps.navy.mil tock.usnogps.navy.mil"
named_flags="-c /etc/namedb/named.conf"
ifconfig_xl0="inet netmask"
ifconfig_xl1="inet netmask"
ifconfig_xl1_alias0="inet netmask"
ifconfig_xl1_alias1="inet netmask"

Dennis Glatting

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to