#include <stdio.h>
#include <sys/types.h>
#include <malloc.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#define HUGE 3000000
static pid_t pid;
int kids = 1;
void killer(int unused)
{
kill(SIGTERM, -1);
signal(SIGALRM, killer);
alarm(2);
}
void reaper(int unused)
{
while((wait3(0, WNOHANG, NULL)) > 0)
;
signal(SIGCHLD, reaper);
if(!(kids--))
exit(0);
}
int main(void);
int main()
{
int i;
char *ptr;
reaper(0); /* Note */
for(i = 0; i < 200 ; i++)
{
switch((pid=fork()))
{
case 0:
(void) close(0);
(void) close(1);
(void) close(2);
if((ptr = (char *) malloc(HUGE * sizeof(char))) == NULL)
return(0);
signal(SIGALRM, killer);
alarm(2);
for(i=0; i< HUGE; i++)
ptr[i]= (char) (i & 0xff);
free(ptr);
pause();
exit(0);
break;
case -1:
fprintf(stderr, "fork failed!\n");
return -1;
default:
kids++;
break;
}
}
pause();
return 0;
}
... will cause the following ...
Mar 20 17:34:57 chaos kernel: swap_duplicate: entry 000fc500 map count=126
Mar 20 17:35:25 chaos kernel: swap_duplicate: entry 000fc000 map count=126
Mar 20 17:35:25 chaos kernel: swap_duplicate: entry 000fc500 map count=127
Mar 20 17:35:25 chaos kernel: swap_duplicate: entry 000fc000 map count=127
Mar 20 17:35:25 chaos kernel: swap_duplicate: entry 000fc500 map count=127
... to be logged.
Executing `swapoff` after these errors will crash (hang) the machine.
The machine runs otherwise. The crash occurs upon shutdown when swapoff
is executed.
Here is /proc/meminfo after the program exits.
total: used: free: shared: buffers: cached:
Mem: 31498240 6295552 25202688 1957888 282624 2883584
Swap: 133885952 1884160 132001792
MemTotal: 30760 kB
MemFree: 24612 kB
MemShared: 1912 kB
Buffers: 276 kB
Cached: 2816 kB
SwapTotal: 130748 kB
SwapFree: 128908 kB
The test program executed fine on the last 5 or 6 previous versions
of Linux. Note that the program is not a `killer` program. It is
designed to thrash a bit, but will eventually exit.
Cheers,
Dick Johnson
***** FILE SYSTEM MODIFIED *****
Penguin : Linux version 2.1.90 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu