[Gc] Premature collection

Tommaso Tagliapietra (EXT VE SYS) tommaso.tagliapietra at enel.it
Wed Nov 14 03:40:31 PST 2007


I'm a problem with the collector (version 6.7, Cygwin, Windows Xp) and
my application in this code:

static  inline void throw_ftp(void)
{
  static object_t *tag = NULL;
  
  if (tag == NULL)
    tag = symbol_new("ftp", nil);
   
  throw(tag, NULL);
}


Symbol_new create an object of this structure:

    typedef struct symbol_t {
      object_t  _super;
      flag_t    s_bound;
      char_t   *s_name;
      object_t *s_value;
      object_t *s_next;
    } symbol_t;

Initializing s_name with the string "ftp".

This object si created with GC_MALLOC and s_name is initialized with a
combination of GC_MALLOC_ATOMIC and memcpy. When my application do a lot
of things with 5 concurrent threads, and ftp transfer fail, there is 5
concurrent invocation of the throw_ftp function. The line "throw(tag,
NULL)" do only a check with an allocated list and then use longjmp to
return to the right place of process execution. The problem is: why
tag->s_name points to another string? I must protect tag adding it to
the GC roots? 

However the following code run correctly...but it's correct to do this?


static  inline void throw_ftp(void)
{
  static object_t *tag = NULL;
  
  if (tag == NULL)
    {
      tag = symbol_new("ftp", nil);
      GC_add_roots((char *)tag, (char *)(tag + sizeof(void *)));
    }
   
  throw(tag, NULL);
}


Thanks for your attention and best regards,
	Tommaso.





More information about the Gc mailing list