return the stack base == 0 in my MIPS platform

Bin Chen binary.chen@gmail.com
Tue Feb 19 16:17:00 GMT 2008


Hi,

The following code returns stack base  = 0, this eventually cause my
program segment fault, can anyone tell me whats wrong and how to fix
it?

Thanks.
Bin

#include <pthread.h>

int stackbase = 0, stacksize = 0;
main()
{
        pthread_attr_t sattr;
        pthread_attr_init(&sattr);
        pthread_t thread;

        thread = pthread_self();
        pthread_getattr_np(thread, &sattr);
        int rc = pthread_attr_getstack(&sattr, &stackbase,
&stacksize);
        if (rc != 0) {
                printf("error.\n");
                exit(1);
        }

        printf("base %x, size %x\n", stackbase, stacksize);

        return;
}


# ./p
base 0, size 2ab56e40



More information about the Libc-alpha mailing list