[ruby-cvs:66481] nagachika:r59303 (ruby_2_4): merge revision(s) 58696: [Backport #11384]

nagachika at ruby-lang.org nagachika at ruby-lang.org
Mon Jul 10 05:46:10 JST 2017

nagachika	2017-07-10 05:46:10 +0900 (Mon, 10 Jul 2017)

  New Revision: 59303


    merge revision(s) 58696: [Backport #11384]
    autoload: always wait on loading thread
    We cannot assume autoload_provided/rb_feature_provided returning
    TRUE means it is safe to proceed without waiting.  Another
    thread may call rb_provide_feature before setting the constant
    (via autoload_const_set).  So we must wait until autoload is
    completed by another thread.
    Note: this patch was tested with an explicit rb_thread_schedule
    in rb_provide_feature to make the race condition more apparent
    as suggested by <s.wanabe at gmail.com>:
    > --- a/load.c
    > +++ b/load.c
    > @@ -563,6 +563,7 @@ rb_provide_feature(VALUE feature)
    >      rb_str_freeze(feature);
    >      rb_ary_push(features, rb_fstring(feature));
    > +rb_thread_schedule();
    >      features_index_add(feature, INT2FIX(RARRAY_LEN(features)-1));
    >      reset_loaded_features_snapshot();
    >  }
    * variable.c (check_autoload_required): do not assume a provided
      feature means autoload is complete, always wait if autoload is
      being performed by another thread.
      [ruby-core:81105] [Bug #11384] Thanks to <s.wanabe at gmail.com>

  Modified directories:
  Modified files:

More information about the ruby-cvs mailing list