I'm trying to use ucontext to create a thread library but I'm segfaulting. I'm using the debugger so I know what the problem is but I don't really understand why. Using debugger I can see that the ucontext_ptr2 in Thread struct is always 0. The ucontext_ptr that I declared in the method however, does get a value but I just put that in as a test so when I call getContext it fails.
Code:struct Thread { char* stack; ucontext_t* ucontext_ptr; int heldLock; int blockedLock; int cv; }; int thread_create(thread_startfunc_t func, void *arg) { cout << "Creating Thread" << endl; Thread* t = new Thread; ucontext_t* ucontext_ptr2; t->heldLock = -1; t->blockedLock = -1; t->cv = -1; getcontext(t->ucontext_ptr); //////more code