mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
thread_sync.c: avoid reaching across stacks of dead threads rb_ensure is insufficient cleanup for fork and we must reinitialize all waitqueues in the child process. Unfortunately this increases the footprint of ConditionVariable, Queue and SizedQueue by 8 bytes on 32-bit (16 bytes on 64-bit). [ruby-core:86316] [Bug #14634] 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] thread_sync: redo r62934 to use fork_gen Instead of maintaining linked-lists to store all rb_queue/rb_szqueue/rb_condvar structs; store only a fork_gen serial number to simplify management of these items. This reduces initialization costs and avoids the up-front cost of resetting all Queue/SizedQueue/ConditionVariable objects at fork while saving 8 bytes per-structure on 64-bit. There are no savings on 32-bit. * thread.c (rb_thread_atfork_internal): remove rb_thread_sync_reset_all call * thread_sync.c (rb_thread_sync_reset_all): remove * thread_sync.c (queue_live): remove * thread_sync.c (queue_free): remove * thread_sync.c (struct rb_queue): s/live/fork_gen/ * thread_sync.c (queue_data_type): use default free * thread_sync.c (queue_alloc): remove list_add * thread_sync.c (queue_fork_check): new function * thread_sync.c (queue_ptr): call queue_fork_check * thread_sync.c (szqueue_free): remove * thread_sync.c (szqueue_data_type): use default free * thread_sync.c (szqueue_alloc): remove list_add * thread_sync.c (szqueue_ptr): check fork_gen via queue_fork_check * thread_sync.c (struct rb_condvar): s/live/fork_gen/ * thread_sync.c (condvar_free): remove * thread_sync.c (cv_data_type): use default free * thread_sync.c (condvar_ptr): check fork_gen * thread_sync.c (condvar_alloc): remove list_add [ruby-core:86316] [Bug #14634] thread_sync.c (condvar_ptr): reset fork_gen after forking Otherwise the condition variable waiter list will always be empty, which is wrong :x [Bug #14725] [Bug #14634] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@66912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e |
||
|---|---|---|
| .. | ||
| enc | ||
| allpairs.rb | ||
| beginmainend.rb | ||
| bug-11928.rb | ||
| bug-13526.rb | ||
| lbtest.rb | ||
| marshaltestlib.rb | ||
| sentence.rb | ||
| test_alias.rb | ||
| test_argf.rb | ||
| test_arity.rb | ||
| test_array.rb | ||
| test_assignment.rb | ||
| test_autoload.rb | ||
| test_backtrace.rb | ||
| test_basicinstructions.rb | ||
| test_beginendblock.rb | ||
| test_bignum.rb | ||
| test_call.rb | ||
| test_case.rb | ||
| test_class.rb | ||
| test_clone.rb | ||
| test_comparable.rb | ||
| test_complex.rb | ||
| test_complex2.rb | ||
| test_complexrational.rb | ||
| test_condition.rb | ||
| test_const.rb | ||
| test_continuation.rb | ||
| test_defined.rb | ||
| test_dir.rb | ||
| test_dir_m17n.rb | ||
| test_econv.rb | ||
| test_encoding.rb | ||
| test_enum.rb | ||
| test_enumerator.rb | ||
| test_env.rb | ||
| test_eval.rb | ||
| test_exception.rb | ||
| test_fiber.rb | ||
| test_file.rb | ||
| test_file_exhaustive.rb | ||
| test_fixnum.rb | ||
| test_flip.rb | ||
| test_float.rb | ||
| test_fnmatch.rb | ||
| test_gc.rb | ||
| test_hash.rb | ||
| test_ifunless.rb | ||
| test_integer.rb | ||
| test_integer_comb.rb | ||
| test_io.rb | ||
| test_io_m17n.rb | ||
| test_iseq.rb | ||
| test_iterator.rb | ||
| test_keyword.rb | ||
| test_lambda.rb | ||
| test_lazy_enumerator.rb | ||
| test_literal.rb | ||
| test_m17n.rb | ||
| test_m17n_comb.rb | ||
| test_marshal.rb | ||
| test_math.rb | ||
| test_metaclass.rb | ||
| test_method.rb | ||
| test_mixed_unicode_escapes.rb | ||
| test_module.rb | ||
| test_not.rb | ||
| test_notimp.rb | ||
| test_numeric.rb | ||
| test_object.rb | ||
| test_objectspace.rb | ||
| test_optimization.rb | ||
| test_pack.rb | ||
| test_parse.rb | ||
| test_path.rb | ||
| test_pipe.rb | ||
| test_primitive.rb | ||
| test_proc.rb | ||
| test_process.rb | ||
| test_rand.rb | ||
| test_range.rb | ||
| test_rational.rb | ||
| test_rational2.rb | ||
| test_readpartial.rb | ||
| test_refinement.rb | ||
| test_regexp.rb | ||
| test_require.rb | ||
| test_rubyoptions.rb | ||
| test_rubyvm.rb | ||
| test_settracefunc.rb | ||
| test_signal.rb | ||
| test_sleep.rb | ||
| test_sprintf.rb | ||
| test_sprintf_comb.rb | ||
| test_string.rb | ||
| test_stringchar.rb | ||
| test_struct.rb | ||
| test_super.rb | ||
| test_symbol.rb | ||
| test_syntax.rb | ||
| test_system.rb | ||
| test_thread.rb | ||
| test_threadgroup.rb | ||
| test_time.rb | ||
| test_time_tz.rb | ||
| test_trace.rb | ||
| test_transcode.rb | ||
| test_undef.rb | ||
| test_unicode_escape.rb | ||
| test_variable.rb | ||
| test_vm_dump.rb | ||
| test_weakmap.rb | ||
| test_whileuntil.rb | ||
| test_yield.rb | ||
| ut_eof.rb | ||