[Gc] GC and Coroutines

Juan Wajnerman jwajnerman at manas.com.ar
Tue Jan 28 13:59:36 PST 2014


The following code works fine, but if you uncomment the commented line, it crashes:

#include <gc/gc.h>
#include <pcl.h>
#include <stdio.h>

void coroutine(void *arg)
{
  int i;
  for (i = 0; i < 1000; ++i)
  {
    printf("%d\n", i);
    GC_malloc(1024);
  }
}

#define STACK_SIZE 32 * 1024
coroutine_t c;

int main(int argc, char const *argv[])
{
  GC_init();
  // GC_malloc(1024);

  c = co_create(coroutine, 0, 0, STACK_SIZE);
  co_call(c);

  return 0;
}



On Jan 28, 2014, at 6:51 PM, Basile Starynkevitch <basile at starynkevitch.net> wrote:

> On Tue, 2014-01-28 at 18:35 -0300, Juan Wajnerman wrote:
>> 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.
>> 
> 
> 
> Show the actual code if possible ... I'm not sure to understand you
> well..
> 
> Cheers.
> -- 
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mine, sont seulement les miennes} ***
> 
> 




More information about the Gc mailing list