[haiku-development] Re: The Haiku stack end is not aligned

> Back when I was first testing JavaScriptCore on Haiku I was getting
> some segfaults when the garbage collector would run. I eventually
> figured out that the problem was a loop whose termination condition
> was p != e. Apparently the two pointers were not aligned perfectly so
> the loop would keep running, eventually hitting invalid memory.

Note that gcc2 doesn't obey alignment (__attribute__(align(n))...) for
stack variables, which cause problems for ffmpeg for example...
but that's not the cause here.

> I turned on a DEBUG build and it turns out the pointer that is not
> aligned is e, which is the stack base (which is called stack end in
> Haiku.) Here is the code I use to get this:

[root@laptop ~]# ./teststack
b 0xfc000f00, e 0xfcffcf00

This is in Zeta.
If you get an 0xXXXXXff or something then it's a bug in Haiku.
It's probably using the last valid address before the end of the last
page, which is different from the value returned by BeOS, which seems
to be the address of the first page after the stack.

François.
#include <OS.h>
#include <stdio.h>

int main(void)
{
        thread_info ti;
        get_thread_info(find_thread(NULL), &ti);
        printf("b %p, e %p\n", ti.stack_base, ti.stack_end);
        return 0;
}

Other related posts: