[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GC Errors in Embedded Program



Quoting Brent Fulgham:
> Looking back at the earlier stack dump, it looks like
> MzScheme is really only happy if it get's called by the main
> thread created by the OS when the program starts.

Now that you mention it, I can see how the GC might require the main
thread on certain platforms. It depends on how the GC finds the stack
base. For version 103, it worked for Windows and x86 Linux, but...

With the GC upgrade (version 103.4), I see that the stack-base routine
changed for x86 Linux. Now it will always find the base of the main
thread's stack.

If the Boehm GC supports threads for your platform, then you might be
able to fix the problem by turning on an appropriate compilation flag.
(For Linux, it's either -DLINUX_THREADS or -DGC_LINUX_THREADS,
depending on which version of the GC you have.)

> Could this problem be resolved using the SGC collector instead?

Yes --- provided that you can get SGC to work. 

The reason SGC might work is that it expects some cooperation from the
allocating program:

 * The allocating program must tell SGC where the stack starts by
   calling GC_set_stack_base(). See plt/src/mzscheme/main.c for an
   example call.

 * SGC generally does not find static variables automatically. They
   must be registered explicitly. The MZ_REGISTER_STATIC() macro
   (defined in scheme.h) can be applied to a static variable to
   register it. Register a variable only once, and before any GCable
   pointer is stored in it.

Also, I just noticed that PAD_BOUNDARY_BYTES was left on in sgc.c.
You'll want to turn that off.

Matthew