tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Stack weirdness causing bugs in GCs


I have discovered that increasing the stack size causes crashes in
applications with garbage collectors, particulary webkit and mono.

I have a test program, which gets the address and size of the stack
in the same way as mono does:

#include <stdio.h>
#include <pthread.h>

        pthread_attr_t attr;
        void *addr;
        size_t size;

        pthread_attr_get_np(pthread_self(), &attr);

        pthread_attr_getstack(&attr, &addr, &size);


        printf("stack address: %p, size: %zu\n", addr, size);

        printf("trying to access %p\n", addr + size - 1);
        volatile char tmp = *(char *)(addr + size - 1);

        return 0;

At the last few lines I try to poke the end of the stack and it crashes when
the stack is larger than 8 megabytes.

For example setting to 64M:  ulimit -s $((64 * 1024)), causes it to crash.

Is the returned information correct? What could cause this? My test system
is i386, maybe its platform dependent? I'm yet to try it on other platforms.
FreeBSD/amd64 seemed to work fine with 512m stacksize.

Any thoughts?

NetBSD - Simplicity is prerequisite for reliability

Home | Main Index | Thread Index | Old Index