Re: GC and Coroutines
Kjetil Matheussen <[email protected]>
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <CAC6niELCUMzrr5QpFaHVVDn_iqk0u+gAZYM9sMnH_ovqJ4A5qw@mail.gmail.com> |
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)))