summaryrefslogtreecommitdiff
path: root/include/ruby/ruby.h
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2025-11-17 21:28:51 -0500
committergit <svn-admin@ruby-lang.org>2025-11-19 02:08:49 +0000
commit69b1c567d71b269edb59a026a9a9f04a6a9a0a49 (patch)
tree6a83aed869ae2d2a63791fd073516b790197759a /include/ruby/ruby.h
parent1f2913e7417f5193ba52028e2a18c1e01b10d358 (diff)
[ruby/mmtk] Add VM barrier in rb_gc_impl_before_fork
We need the VM barrier in rb_gc_impl_before_fork to stop the other Ractors because otherwise they could be allocating objects in the fast path which could be calling mmtk_add_obj_free_candidate. Since mmtk_add_obj_free_candidate acquires a lock on obj_free_candidates in weak_proc.rs, this lock may not be released in the child process after the Ractor dies. For example, the following script demonstrates the issue: puts "Hello #{Process.pid}" 100.times do |i| puts "i = #{i}" Ractor.new(i) do |j| puts "Ractor #{j} hello" 1000.times do |i| s = "#{j}-#{i}" end Ractor.receive puts "Ractor #{j} goodbye" end pid = fork { } puts "Child pid is #{pid}" _, status = Process.waitpid2 pid puts status.success? end puts "Goodbye" In the child process, we can see that it is stuck trying to acquire the lock on obj_free_candidates: #5 0x00007192bfb53f10 in mmtk_ruby::weak_proc::WeakProcessor::get_all_obj_free_candidates (self=0x7192c0657498 <mmtk_ruby::BINDING+72>) at src/weak_proc.rs:52 #6 0x00007192bfa634c3 in mmtk_ruby::api::mmtk_get_all_obj_free_candidates () at src/api.rs:295 #7 0x00007192bfa61d50 in rb_gc_impl_shutdown_call_finalizer (objspace_ptr=0x578c17abfc50) at gc/mmtk/mmtk.c:1032 #8 0x0000578c1601e48e in rb_ec_finalize (ec=0x578c17ac06d0) at eval.c:166 #9 rb_ec_cleanup (ec=<optimized out>, ex=<optimized out>) at eval.c:257 #10 0x0000578c1601ebf6 in ruby_cleanup (ex=<optimized out>) at eval.c:180 #11 ruby_stop (ex=<optimized out>) at eval.c:292 #12 0x0000578c16127124 in rb_f_fork (obj=<optimized out>) at process.c:4291 #13 rb_f_fork (obj=<optimized out>) at process.c:4281 https://github.com/ruby/mmtk/commit/eb4b229858
Diffstat (limited to 'include/ruby/ruby.h')
0 files changed, 0 insertions, 0 deletions