/proc reading causing exception

Daryll Strauss (daryll@d2.com)
Wed, 26 Nov 1997 12:01:54 -0800


I reported this bug against an earlier kernel (2.1.42) but hadn't heard
anything. Since I read that recent kernels improved /proc file handling
I repeated my test on 2.1.62. It still failes. This is running on an Alpha.

It is fairly easy to reproduce. I've got a small application that will
eat up a lot of memory on the machine. The swapping appears to slow
things down enough for the condition to occur. I then use the shell to
repeatedly run ps. Eventually ps will die with an exception:

Nov 21 02:17:03 sw-linux-2-e kernel: ps: Exception at [<fffffc0000312014>] (fffffc0000312024)
Nov 21 02:17:03 sw-linux-2-e kernel: ps: unhandled unaligned exception at pc=fffffc0000366eec ra=fffffc00003674cc (bad address = 814b164900010002)

If I lookup the address in my ksyms I see

fffffc0000366eb0 t get_wchan ___fffffc0000366eec

I've enclosed the little memory hog program for anyone else who wants to
try this. Make sure you have a reasonable amount of swap.

- |Daryll

// ram-hog.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
main() {
unsigned long total = 0;
char *s;
int size = 10000000;
while (s = (char*)malloc(size) ) {
memset(s, 0xaa, size);
total += size;
fprintf(stderr,"%lu\n",total);
sleep(1);
}
}