[ruby-cvs:70477] normal:r63387 (trunk): variable.c: fix multiple autoload with identical file

normal at ruby-lang.org normal at ruby-lang.org
Thu May 10 10:19:20 JST 2018

normal	2018-05-10 10:19:20 +0900 (Thu, 10 May 2018)

  New Revision: 63387


    variable.c: fix multiple autoload with identical file
    We need to ensure autoload declarations pointing to the same
    feature (aka "file") can wait on each other to avoid deadlock
    So, reorganize autoload data structures to maintain a
    feature => autoload_data_i mapping, and have module constant
    tables point to the new autoload_const struct instead of
    directly to autoload_data_i.  This allows multiple
    autoload_const structs to refer to the SAME autoload_data_i
    struct, and with it, the on-stack autoload_state.waitq.
    The end result is different constants can share the same waitq
    (tied to the feature name), and not deadlock each other during
    Thanks to Eugene Kenny for the bug report and reproducible test case.
    Reported-by: Eugene Kenny <elkenny at gmail.com>
    * variable.c (autoload_featuremap): new global
      (struct autoload_const): new per-const struct
      (struct autoload_state): reference autoload_const instead of autoload_data_i
      (struct autoload_data_i): remove per-const
      (autoload_i_mark): delete from autoload_featuremap if unreferenced
      (autoload_c_mark): new dmark callback
      (autoload_c_free): new dfree callback
      (autoload_c_memsize): new memsize callback
      (autoload_const_type): new data type
      (get_autoload_data): set autoload_const as well
      (rb_autoload_str): use new data structures
      (autoload_delete): cleanup from autoload_featuremap
      (check_autoload_required): adjust for new internals
      (rb_autoloading_value): ditto
      (struct autoload_const_set_args): remove, redundant with autoload_const
      (const_tbl_update): adjust for new internals
      (autoload_const_set): ditto
      (autoload_require): ditto
      (autoload_reset): ditto
      (rb_autoload_load): ditto
      (rb_const_set): ditto
      (current_autoload_data): ditto
      (set_const_visibility): ditto
    * test/ruby/test_autoload.rb (test_autoload_same_file): new test
      [ruby-core:86935] [Bug #14742]

  Modified files:

More information about the ruby-cvs mailing list