Project

General

Profile

« Previous | Next » 

Revision ec959fbb

Added by normal almost 6 years ago

variable.c: fix multiple autoload with identical file (again)

We need to ensure autoload declarations pointing to the same
feature (aka "file") can wait on each other to avoid deadlock
situations.

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
loading.

Thanks to Eugene Kenny for the bug report and reproducible test case.

Reported-by: Eugene Kenny

  • 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
    (test_no_leak): new test
    [ruby-core:86935] [Bug #14742]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e