From b456eab2ea77eda51c8d5c06c24d195a6a2932e1 Mon Sep 17 00:00:00 2001 From: normal Date: Fri, 20 Apr 2018 03:22:26 +0000 Subject: variable.c: fix thread + fork errors in autoload This is fairly non-intrusive bugfix to prevent children from trying to reach into thread stacks of the parent. I will probably reuse this idea and redo r62934, too (same bug). * vm_core.h (typedef struct rb_vm_struct): add fork_gen counter * thread.c (rb_thread_atfork_internal): increment fork_gen * variable.c (struct autoload_data_i): store fork_gen * variable.c (check_autoload_data): remove (replaced with get_...) * variable.c (get_autoload_data): check fork_gen when retrieving * variable.c (check_autoload_required): use get_autoload_data * variable.c (rb_autoloading_value): ditto * variable.c (rb_autoload_p): ditto * variable.c (current_autoload_data): ditto * variable.c (autoload_reset): reset fork_gen, adjust indent * variable.c (rb_autoload_load): set fork_gen when setting state * test/ruby/test_autoload.rb (test_autoload_fork): new test [ruby-core:86410] [Bug #14634] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 1 + 1 file changed, 1 insertion(+) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 1caea4976c..f0ace8326c 100644 --- a/thread.c +++ b/thread.c @@ -4216,6 +4216,7 @@ rb_thread_atfork_internal(rb_thread_t *th, void (*atfork)(rb_thread_t *, const r } rb_vm_living_threads_init(vm); rb_vm_living_threads_insert(vm, th); + vm->fork_gen++; rb_thread_sync_reset_all(); vm->sleeper = 0; -- cgit v1.2.3