[Gc] GC and Coroutines
jwajnerman at manas.com.ar
Tue Jan 28 13:35:32 PST 2014
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 <k.s.matheussen at gmail.com> wrote:
> On Tue, Jan 28, 2014 at 9:36 PM, Juan Wajnerman <jwajnerman at manas.com.ar> 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:
>> 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)))
More information about the Gc