On Sat, Nov 22, 2008 at 12:49:27AM +0900, Brian Mitchell wrote:
> I would imagine it would be possible to have a C extension provide
> working fibers as long as the GC was made aware of the stack so it
> could scan the stacks appropriately.

If the GC is invoked while in another thread, the calculated stack end
address will be wrong, and the GC will try to mark all the memory
between the main thread's stack start and the current thread's stack
end.

So I think it could be made to work if before switching threads:
  - ruby's thread start address is changed to point to the new thread's
    start address
  - the old thread's end address is saved in a globally accessible
    object

Then, as you pointed out, on gc invocation, each thread can mark its own
stack.

> Threads would also probably have to be modified a bit to work in
> concert (jumping back to the proper fiber before making the context
> switch I would guess).

Probably simpler would be to disable Thread altogether for a first pass.

Paul