Am Donnerstag, 19. Juli 2007 02:48 schrieb Will Coleda:
> I am trying to write a PMC version of PGE::CodeString, and while I  
> have a PMC now that passes all the old tests, I get GC errors during  
> the build process for TGE & JSON.
>
> I know they are GC related because running the affected steps with -
> G, and they complete normally.
>
> I was unable to find a document describing what sorts of things I  
> needed to do; Working with particle (on GC) and allison (on storage),  
> I now have:
>
>      void init() {
>          PMC* counter;
>
>          PMC_str_val(SELF) =
>              string_make_empty(INTERP, enum_stringrep_one, 0);
>          PObj_custom_mark_SET(SELF);
>
>          /* initialized our counter that keeps track of register  
> numbers */
>          counter = pmc_new(INTERP, enum_class_Integer);
>          VTABLE_set_integer_native(INTERP, counter, 10);
>          PMC_data(SELF) = counter;
>      }

The problem is as follows:

1) PObj_custom_mark_SET(SELF);
2) counter = pmc_new(INTERP, enum_class_Integer);
3) PMC_data(SELF) = counter;

In 1) you enable marking. 2) might cause a garbage collection, while the 
integer PMC isn't yet anchored. This is only done at step 3).

PMC_data(SELF) = pmc_new ...

should fix it, maybe along with doing 1) after all things are created.

leo

Reply via email to