makecontext not enough storage for stack

68 Views Asked by At

I try to make a header file in C that virtualizes all function calls from ucontext.h library.

Everything is working fine except for function makecontext() when I try to call my_makecontext() I get this message:

not enough storage for stack: Success
Aborted (core dumped)

But when I use makecontext instead of my function everything is working fine.

I am struggling to solve it.

A snippet of my code is:

test_file_for_my_funcs.c

//Doesn't work
//makecontext(&context.uctx_source,(void*)Write,1,*length);
//makecontext(&context.uctx_target,(void*)Read,0);
mycoroutines_create(&context.uctx_source,(void *)Write,length);
mycoroutines_create(&context.uctx_target,(void *)Read,length);

mycoroutines.h

int mycoroutines_create(ucontext_t *coroutine,void (body)(void *),void *arg)
{
makecontext(coroutine,(void *)body,1,(int *)arg);
if(errno != 0){
                perror("Error reported by makecontext()");
                return -1;         }
  else {
    perror("not enough storage for stack");
    abort();
  }
  return 0;
}
0

There are 0 best solutions below