Skip site navigation (1)Skip section navigation (2)
Date:      05 Feb 2001 13:12:28 +0100
From:      Jesper Hansen <jesper@funcom.com>
To:        stable@freebsd.org
Subject:   4.2-RELEASE crashes when exiting from process with many open sockets.
Message-ID:  <358znlnxar.fsf@rhino.funcom.com>

next in thread | raw e-mail | index | archive | help

I am developing an IRC like server, and in the process I have crashed
4.2-RELEASE, 4.2-STABLE and 5.0-CURRENT kernels, I have made this
simple program that seems to trigger the same bug:

--8X----8X----8X----8X----8X----8X----8X----8X----8X----8X----8X--
#include <sys/types.h>
#include <sys/socket.h>
int main()
{
  int i;
  for( i=0; i<50000; i++ )
    socket( AF_INET, SOCK_STREAM, 0 );
  return 0;
}
--8X----8X----8X----8X----8X----8X----8X----8X----8X----8X----8X--

Sometimes I have to run it several times before the kernel crashes.

I have not used FreeBSD for a long time, I just choose it for this
project, because I belive FreeBSD, with its kernel queues is the
only free OS that can handle 50k+ connections (with IRC like traffic
patterns). So if anybody can help me I will be gratefull, here's the
relevant information:

/etc/sysctl.conf:
kern.maxfilesperproc=65536
kern.maxfiles=65536
net.inet.ip.portrange.first=1024
net.inet.ip.portrange.last=62000
net.inet.ip.portrange.hifirst=62000
net.inet.ip.portrange.hilast=65535

/sys/i386/conf/CHATKERNEL:
machine         i386
ident           CHATKERNEL
maxusers        16
options         NMBCLUSTERS=60000
options         DDB
makeoptions     DEBUG=-g                #Build kernel with gdb(1) debug symbols
options         MAXDSIZ="(256*1024*1024)"
options         DFLDSIZ="(200*1024*1024)"
options         INET                    #InterNETworking
options         FFS                     #Berkeley Fast Filesystem
options         FFS_ROOT                #FFS usable as root device [keep this!]
options         SOFTUPDATES             #Enable FFS soft updates support
options         NFS                     #Network Filesystem
options         CD9660                  #ISO 9660 Filesystem
options         PROCFS                  #Process filesystem
options         COMPAT_43               #Compatible with BSD 4.3 [KEEP THIS!]
options         SCSI_DELAY=5000         #Delay (in ms) before probing SCSI
options         UCONSOLE                #Allow users to grab the console
options         USERCONFIG              #boot -c editor
options         VISUAL_USERCONFIG       #visual boot -c editor
options         KTRACE                  #ktrace(1) support
options         SYSVSHM                 #SYSV-style shared memory
options         SYSVMSG                 #SYSV-style message queues
options         SYSVSEM                 #SYSV-style semaphores
options         P1003_1B                #Posix P1003_1B real-time extensions
options         _KPOSIX_PRIORITY_SCHEDULING
options         KBD_INSTALL_CDEV        # install a CDEV entry in /dev
device          isa
device          eisa
device          pci
device          fdc0    at isa? port IO_FD1 irq 6 drq 2
device          fd0     at fdc0 drive 0
device          ata0    at isa? port IO_WD1 irq 14
device          ata1    at isa? port IO_WD2 irq 15
device          ata
device          atadisk                 # ATA disk drives
options         ATA_STATIC_ID           #Static device numbering
options         ATA_ENABLE_ATAPI_DMA    #Enable DMA on ATAPI devices
device          ahc             # AHA2940 and onboard AIC7xxx devices
device          sym             # NCR/Symbios Logic (newer chipsets)
options         SYM_SETUP_LP_PROBE_MAP=0x40
device          scbus           # SCSI bus (required)
device          da              # Direct Access (disks)
device          cd              # CD
device          pass            # Passthrough device (direct SCSI access)
device          atkbdc0 at isa? port IO_KBD
device          atkbd0  at atkbdc? irq 1 flags 0x1
device          psm0    at atkbdc? irq 12
device          vga0    at isa?
pseudo-device   splash
device          sc0     at isa? flags 0x100
device          npx0    at nexus? port IO_NPX irq 13
device          apm0    at nexus? disable flags 0x20 # Advanced Power Management
device          sio0    at isa? port IO_COM1 flags 0x10 irq 4
device          sio1    at isa? port IO_COM2 irq 3
device          ppc0    at isa? irq 7
device          ppbus           # Parallel port bus (required)
device          lpt             # Printer
device          ppi             # Parallel port interface device
device          fxp             # Intel EtherExpress PRO/100B (82557, 82558)
device          miibus          # MII bus support
device          xl              # 3Com 3c90x (``Boomerang'', ``Cyclone'')
pseudo-device   loop            # Network loopback
pseudo-device   ether           # Ethernet support
pseudo-device   tun             # Packet tunnel.
pseudo-device   pty             # Pseudo-ttys (telnet etc)
pseudo-device   bpf             #Berkeley packet filter

gdb output:
IdlePTD 3354624
initial pcb at 2ac640
panicstr: from debugger
panic messages:
---
panic: free: multiple frees
panic: from debugger
Uptime: 2m2s

dumping to dev #da/0x30001, offset 533088
dump 255 254 253 252 251 250 249 248 247 246 245 244 243 242 241 240 239 238 237 236 235 234 233 232 231 230 229 228 227 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 209 208 207 206 205 204 203 202 201 200 199 198 197 196 195 194 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 
---
#0  dumpsys () at ../../kern/kern_shutdown.c:469
469             if (dumping++) {
(kgdb) where
#0  dumpsys () at ../../kern/kern_shutdown.c:469
#1  0xc0158c5f in boot (howto=260) at ../../kern/kern_shutdown.c:309
#2  0xc0158ff5 in panic (fmt=0xc025c194 "from debugger") at ../../kern/kern_shutdown.c:556
#3  0xc012c6f1 in db_panic (addr=-1071417724, have_addr=0, count=-1, modif=0xdb596ba8 "")
    at ../../ddb/db_command.c:433
#4  0xc012c691 in db_command (last_cmdp=0xc028a9fc, cmd_table=0xc028a85c, aux_cmd_tablep=0xc02a7b64)
    at ../../ddb/db_command.c:333
#5  0xc012c756 in db_command_loop () at ../../ddb/db_command.c:455
#6  0xc012e863 in db_trap (type=3, code=0) at ../../ddb/db_trap.c:71
#7  0xc0237426 in kdb_trap (type=3, code=0, regs=0xdb596cb0) at ../../i386/i386/db_interface.c:158
#8  0xc0242fdc in trap (frame={tf_fs = -635437040, tf_es = -614858736, tf_ds = 16, tf_edi = -1062959984, 
      tf_esi = 256, tf_ebp = -614896392, tf_isp = -614896420, tf_ebx = -1071239969, tf_edx = 0, tf_ecx = 0, 
      tf_eax = 18, tf_trapno = 3, tf_err = 0, tf_eip = -1071417724, tf_cs = 8, tf_eflags = 582, 
      tf_esp = -1071129889, tf_ss = -1071236989}) at ../../i386/i386/trap.c:569
#9  0xc0237684 in Debugger (msg=0xc0263883 "panic") at machine/cpufunc.h:64
#10 0xc0158fec in panic (fmt=0xc0262cdf "free: multiple frees") at ../../kern/kern_shutdown.c:554
#11 0xc015490f in free (addr=0xcbb81b80, type=0xc0292c60) at ../../kern/kern_malloc.c:371
#12 0xc0171b82 in cblock_free_cblocks (number=22) at ../../kern/tty_subr.c:194
#13 0xc0171bb8 in clist_free_cblocks (clistp=0xcbb55f38) at ../../kern/tty_subr.c:208
#14 0xc016cfd2 in ttyclose (tp=0xcbb55f00) at ../../kern/tty.c:247
#15 0xc022faab in scclose (dev=0xcba5eb80, flag=3, mode=8192, p=0xda20a440) at ../../dev/syscons/syscons.c:560
#16 0xc01709d9 in cnclose (dev=0xcba5eb80, flag=3, mode=8192, p=0xda20a440) at ../../kern/tty_cons.c:324
#17 0xc018fb60 in spec_close (ap=0xdb596e10) at ../../miscfs/specfs/spec_vnops.c:572
#18 0xc0208e1a in ufsspec_close (ap=0xdb596e10) at ../../ufs/ufs/ufs_vnops.c:1884
#19 0xc0209279 in ufs_vnoperatespec (ap=0xdb596e10) at ../../ufs/ufs/ufs_vnops.c:2305
#20 0xc018b540 in vn_close (vp=0xdb5dca80, flags=3, cred=0xc0a66780, p=0xda20a440) at vnode_if.h:218
#21 0xc018bde8 in vn_closefile (fp=0xcbb537c0, p=0xda20a440) at ../../kern/vfs_vnops.c:662
#22 0xc014efd9 in fdrop (fp=0xcbb537c0, p=0xda20a440) at ../../sys/file.h:214
#23 0xc014ef1f in closef (fp=0xcbb537c0, p=0xda20a440) at ../../kern/kern_descrip.c:1208
#24 0xc014ec98 in fdfree (p=0xda20a440) at ../../kern/kern_descrip.c:1049
#25 0xc0151491 in exit1 (p=0xda20a440, rv=256) at ../../kern/kern_exit.c:186
#26 0xc0151308 in exit1 (p=0xda20a440, rv=0) at ../../kern/kern_exit.c:103
#27 0xc0243909 in syscall2 (frame={tf_fs = 47, tf_es = 47, tf_ds = 47, tf_edi = 135288904, tf_esi = 0, 
      tf_ebp = -1077937092, tf_isp = -614895660, tf_ebx = -1, tf_edx = 135015560, tf_ecx = 1, tf_eax = 1, 
      tf_trapno = 22, tf_err = 2, tf_eip = 135024088, tf_cs = 31, tf_eflags = 647, tf_esp = -1077937136, 
      tf_ss = 47}) at ../../i386/i386/trap.c:1150
#28 0xc0237d65 in Xint0x80_syscall ()
#29 0x8048bbb in ?? ()
#30 0x804885f in ?? ()
#31 0x8048135 in ?? ()
(kgdb) up 11
#11 0xc015490f in free (addr=0xcbb81b80, type=0xc0292c60) at ../../kern/kern_malloc.c:371
371                             panic("free: multiple frees");
(kgdb) list
366             freep->type = type;
367     #endif /* INVARIANTS */
368             kup->ku_freecnt++;
369             if (kup->ku_freecnt >= kbp->kb_elmpercl) {
370                     if (kup->ku_freecnt > kbp->kb_elmpercl)
371                             panic("free: multiple frees");
372                     else if (kbp->kb_totalfree > kbp->kb_highwat)
373                             kbp->kb_couldfree++;
374             }
375             kbp->kb_totalfree++;
(kgdb) print kup
$1 = (struct kmemusage *) 0xc0a48490
(kgdb) print *kup
$2 = {ku_indx = 7, ku_un = {freecnt = 33, pagecnt = 33}}
(kgdb) print *kbp
$3 = {kb_next = 0xcbb81b00 "\200\032<B8><CB>", kb_last = 0xcbb81000 "", kb_calls = 2539, kb_total = 1056, 
  kb_elmpercl = 32, kb_totalfree = 32, kb_highwat = 160, kb_couldfree = 0}
(kgdb) up
#12 0xc0171b82 in cblock_free_cblocks (number=22) at ../../kern/tty_subr.c:194
194                     free(cblock_alloc(), M_TTYS);
(kgdb) up
#13 0xc0171bb8 in clist_free_cblocks (clistp=0xcbb55f38) at ../../kern/tty_subr.c:208
208             cblock_free_cblocks(clistp->c_cbreserved);
(kgdb) list
203     clist_free_cblocks(clistp)
204             struct clist *clistp;
205     {
206             if (clistp->c_cbcount != 0)
207                     panic("freeing active clist cblocks");
208             cblock_free_cblocks(clistp->c_cbreserved);
209             clistp->c_cbmax = 0;
210             clistp->c_cbreserved = 0;
211     }
212     
(kgdb) print *clistp
$4 = {c_cc = 0, c_cbcount = 0, c_cbmax = 22, c_cbreserved = 22, c_cf = 0x0, c_cl = 0x0}
(kgdb) up
#14 0xc016cfd2 in ttyclose (tp=0xcbb55f00) at ../../kern/tty.c:247
247             clist_free_cblocks(&tp->t_outq);
(kgdb) list
242             if (constty == tp)
243                     constty = NULL;
244     
245             ttyflush(tp, FREAD | FWRITE);
246             clist_free_cblocks(&tp->t_canq);
247             clist_free_cblocks(&tp->t_outq);
248             clist_free_cblocks(&tp->t_rawq);
249     
250     #if NSNP > 0
251             if (ISSET(tp->t_state, TS_SNOOP) && tp->t_sc != NULL)
(kgdb) print *tp
$5 = {t_rawq = {c_cc = 0, c_cbcount = 0, c_cbmax = 11, c_cbreserved = 11, c_cf = 0x0, c_cl = 0x0}, 
  t_rawcc = 122, t_canq = {c_cc = 0, c_cbcount = 0, c_cbmax = 0, c_cbreserved = 0, c_cf = 0x0, c_cl = 0x0}, 
  t_cancc = 20, t_outq = {c_cc = 0, c_cbcount = 0, c_cbmax = 22, c_cbreserved = 22, c_cf = 0x0, c_cl = 0x0}, 
  t_outcc = 1984, t_line = 0, t_dev = 0xcba5eb80, t_state = 131112, t_flags = 0, t_timeout = 0, 
  t_pgrp = 0xcbb2a8e0, t_session = 0xcbb53600, t_sigio = 0x0, t_rsel = {si_pid = 0, si_note = {slh_first = 0x0}, 
    si_flags = 0}, t_wsel = {si_pid = 0, si_note = {slh_first = 0x0}, si_flags = 0}, t_termios = {
    c_iflag = 11010, c_oflag = 3, c_cflag = 19200, c_lflag = 1483, 
    c_cc = "\004<FF><FF>\b\027\025\022<FF>\003\034\032\031\021\023\026\017\001\000\024<FF>", c_ispeed = 115200, 
    c_ospeed = 115200}, t_winsize = {ws_row = 25, ws_col = 80, ws_xpixel = 0, ws_ypixel = 0}, 
  t_oproc = 0xc0230cf0 <scstart>, t_stop = 0xc016fc94 <nottystop>, t_param = 0xc022fcbc <scparam>, t_sc = 0x0, 
  t_column = 0, t_rocount = 0, t_rocol = 0, t_ififosize = 512, t_ihiwat = 512, t_ilowat = 448, t_ispeedwat = 0, 
  t_ohiwat = 2052, t_olowat = 256, t_ospeedwat = 0, t_gen = 1, t_list = {sle_next = 0xcba49400}}
(kgdb) up
#15 0xc022faab in scclose (dev=0xcba5eb80, flag=3, mode=8192, p=0xda20a440) at ../../dev/syscons/syscons.c:560
560         ttyclose(tp);
(kgdb) up
#16 0xc01709d9 in cnclose (dev=0xcba5eb80, flag=3, mode=8192, p=0xda20a440) at ../../kern/tty_cons.c:324
324                     return ((*cn_phys_close)(dev, flag, mode, p));
(kgdb) bash-2.04# 
bash-2.04# 

--
Jesper Hansen



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?358znlnxar.fsf>