[plt-scheme] GC surprise collection

From: Daniel Silva (daniel.silva at gmail.com)
Date: Sat Sep 4 12:30:32 EDT 2004

In a C extension I have these two functions in two C source files:

moduleobject.c:

PyObject* PyModule_New(char *name)
{
  Scheme_Object* ns = scheme_make_namespace(0, 0);
  assert(SCHEME_NAMESPACEP(o));
  return PyModule_SpyNew(name, PySchemeNS_New((Scheme_Env*) ns));
}

schemensobject.c:

PyObject* PySchemeNS_New(Scheme_Env* ns)
{
  assert(SCHEME_NAMESPACEP((Scheme_Object*)ns));
  ...
  return (PyObject*) ...;
}

The assertion in PySchemeNS_New fails somehow, but if I change
PyModule_New to say:

PyObject* PyModule_New(char *name)
{
  Scheme_Object* ns = scheme_make_namespace(0, 0);
  assert(SCHEME_NAMESPACEP(o));
  scheme_dont_gc_ptr(o);
  return PyModule_SpyNew(name, PySchemeNS_New((Scheme_Env*) ns));
}

then it works.  Is the GC collecting ns in the first case?

Daniel


Posted on the users mailing list.