Bug #2279: When embedding Ruby 1.9.1 it's impossible to disable GC
http://redmine.ruby-lang.org/issues/show/2279

Author: Roman Shterenzon
Status: Open, Priority: Normal
Category: core
ruby -v: ruby 1.9.1p291 (2009-10-25 revision 25484) [i386-darwin10.0.0]

The function vm_xmalloc() will call garbage_collect_with_gvl() even if dont_gc is set by rb_gc_disable().
This is ok (though wastes some CPU cycles) when the code is running in native Ruby interpreter, as later the garbage_collect checks this flag.
What happens in embedded ruby, is that in garbage_collect_with_gvl() the ruby_native_thread_p() returns false, and the process exits with "[FATAL] failed to allocate memory" (so it seems, that the problem is even more serious, as if the GC is enabled, and the code which triggers GC is in C, then the program will exit as well).

I propose not to invoke garbage_collect_with_gvl in the first place, or, exit it right away if dont_gc is true.


----------------------------------------
http://redmine.ruby-lang.org