Re: GC and Coroutines
Juan Wajnerman <[email protected]>
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <[email protected]> |
I made the stack and the coroutine variables (might be the same value, right?) as global but it still crashes. Something I noticed is that when I call co_create() without a stack (it allocates its own stack) it works fine if I didn't call GC_malloc() before. In other words, it crashes if I call GC_malloc() in the main function. On Jan 28, 2014, at 6:16 PM, Kjetil Matheussen <[email protected]> wrote: > On Tue, Jan 28, 2014 at 9:36 PM, Juan Wajnerman <[email protected]> wrote: >> I'm not sure if I understand how I'm supposed to use the GC_stack_base info. >> I tried to call GC_add_root using the mem_base but with no luck so far. >> >> Here is a small example of what I'm trying to run: >> https://gist.github.com/waj/8675658 >> In my machine it crashes after 60 or 70 iterations. >> >> The stack space allocated for the coroutine is also allocated with the GC so >> it shouldn't be necessary to register that area, right? >> > > Yes, but I think the problem with your example is > that the pointer to the stack variable in main is not > tracable inside the coroutine. To test that theory, > it should work if you just make it into a global variable. > > If you run more coroutines, you also need to add > the context of them to the GC roots. > > For my program, it was enough just doing this: > > coroutine_t c > GC_add_root(c, c+ MAX(sizeof(ucontext_t), sizeof(jmp_buf)))