-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

nobu / ruby-lang.org wrote:
>> That's my understanding of the error message. If I am correct, then
>> a solution to this problem would be to prohibit the C program from
>> using Ruby's C API functions. That way, the C program never creates
>> any Ruby objects which can be garbage collected by the embedded Ruby
>> interpreter that runs inside another thread.
> 
> Incorrect.
> 
> You have to ensure rb_gc() will run only in the initial thread,
> and all objects created in your program will be refered from
> somewhere other than the main stack.

IMHO, the only practical to way to implement your suggestion is
through this policy:

1. Code executed by the C process *cannot* use the Ruby C API.

2. Code executed by the Ruby thread *can* use the Ruby C API.

At heart, this policy simply prohibits using the Ruby C API as a
means of inter-process communication between the C process and the
Ruby thread. Other means of inter-process communication, such as
pipes or sockets, can be used instead.


Thus, the resulting scenario looks like this:

{process:
	// *never* use the Ruby C API here

	pthread_create();
	...

	{pthread:
		// use Ruby C API here

		ruby_init();
		...
		ruby_run();
	}

	...
}


Thanks for your advice and explanations.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEQ9QJmV9O7RYnKMcRAh1nAKCk0AN9fwYnkdwE8d4oSvtpokJ+7ACfXhqv
MhSXxTGeUQXHH9Y/MM+cWdE=
=ZbFX
-----END PGP SIGNATURE-----