kayws426 / embox

Automatically exported from code.google.com/p/embox
0 stars 1 forks source link

thread alloc sets incorrect stack #559

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
src/kernel/thread/core.c:512

t->stack = &block->stack + sizeof(struct thread);

is incorrect, since block->start is char[STACK_SZ]. That leads to t->stack 
points far from real stack. Suggested fix is 

t->stack = (void *) &block->stack + sizeof(struct thread);

I'm not fixing myself because that's seems to strange to work earlier.

Original issue reported on code.google.com by drakon.m...@gmail.com on 19 Mar 2013 at 5:08

GoogleCodeExporter commented 9 years ago
More proper fix is to remove an ampersand:
t->stack = block->stack + sizeof(struct thread);

Another solution is to add a flex array member to the end of thread struct:

struct thread {
    ...
    char stack[];
}

Antonishko, feel free to fix it yourself.

Original comment by Eldar.Abusalimov on 19 Mar 2013 at 5:21

GoogleCodeExporter commented 9 years ago
How did it work before???

Original comment by iantonishko on 19 Mar 2013 at 7:58