Subject: kern/5426: out of space in kmem_map
To: None <gnats-bugs@gnats.netbsd.org>
From: Stefan Grefen <grefen@hprc.tandem.com>
List: netbsd-bugs
Date: 05/08/1998 23:01:44
>Number: 5426
>Category: kern
>Synopsis: panic: malloc: out of space in kmem_map
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 8 14:20:00 1998
>Last-Modified:
>Originator: Stefan Grefen
>Organization:
Stefan Grefen Tandem Computers Europe Inc.
grefen@hprc.tandem.com High Performance Research Center
--- Hacking's just another word for nothing left to kludge. ---
>Release: -current <NetBSD-current source date>
>Environment:
NetBSD hicks 1.3E NetBSD 1.3E (CPQ) #11: Thu May 7 22:01:45 CEST 1998 grefen@hicks:/usr/src/sys/arch/i386/compile/CPQ i386
pmap.new uvm Pentium II ??MHZ (Compaq Deskpro 6000)
>Description:
Crash runnin simple socket testprogram.
The testprogram connects to a server and sends/receives 128 bytes
closes the connection and starts all over. Crash happens with ~5000
sockets in TIME_WAIT. Machine IDLE.
It happens with local and remote clients.
I think somehow the defaults for the size various memmory regions are
suboptimal (I could understand bind/socket/write failing with ENOMEM)
or the TIME_WAIT period is too long.
This works on everything from NT over Solaris , unixware to BSDI 2.1
with SMP patches).
I know the programs below can be 'optimized' these is just the
benchmark boiled down to the essintials.
>How-To-Repeat:
server.c:
#include <stdio.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
int buffer[1024];
main() {
int s=socket(AF_INET,SOCK_STREAM,NULL);
struct sockaddr_in sin;
bzero(&sin,sizeof(sin));
sin.sin_family=AF_INET;
sin.sin_len=sizeof(sin);
sin.sin_port=htons(4321);
bind(s,&sin,sizeof(sin));
listen(s,5);
while(1) {
int slen=sizeof(sin);
int w=accept(s,&sin,&slen);
int l=recv(w,buffer,128,0);
if(l<=0)
exit(!!l);
send(w,buffer,l,0);
close(w);
}
}
client.c:
#include <stdio.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
int buffer[1024];
main(int argc,char **argv) {
while(1) {
int s=socket(AF_INET,SOCK_STREAM,NULL);
struct sockaddr_in sin;
bzero(&sin,sizeof(sin));
sin.sin_family=AF_INET;
sin.sin_len=sizeof(sin);
sin.sin_port=htons(4321);
inet_aton(argv[1],&sin.sin_addr);
if(connect(s,&sin,sizeof(sin))<0) {
perror("connect");
} else {
send(s,buffer,128,0);
recv(s,buffer,128,0);
}
close(s);
}
}
$ server &
$ client 127.0.0.1 &
>Fix:
>Audit-Trail:
>Unformatted: