[ruby-cvs:70896] usa:r63805 (ruby_2_4): merge revision(s) 62396: [Backport #14357]

usa at ruby-lang.org usa at ruby-lang.org
Sat Jun 30 21:56:17 JST 2018

usa	2018-06-30 21:56:17 +0900 (Sat, 30 Jun 2018)

  New Revision: 63805


    merge revision(s) 62396: [Backport #14357]
    st.c: retry operations if rebuilt
    Calling the .eql? and .hash methods during a Hash operation can
    result in a thread switch or a signal handler to run: allowing
    one execution context to rebuild the hash table while another is
    still reading or writing the table.  This results in a
    use-after-free bug affecting the thread_safe-0.3.6 test suite
    and likely other bugs.
    This bug did not affect users of commonly keys (String, Symbol,
    Fixnum) as those are optimized to avoid method dispatch
    for .eql? and .hash methods.
    A separate version of this change needs to be ported to Ruby 2.3.x
    which had a different implementation of st.c but was affected
    by the same bug.
    * st.c: Add comment about table rebuilding during comparison.
      (DO_PTR_EQUAL_CHECK): New macro.
      (find_entry, find_table_entry_ind, find_table_bin_ind): Use new
      macros.  Return the rebuild flag.
      (find_table_bin_ptr_and_reserve): Ditto.
      (st_lookup, st_get_key, st_insert, st_insert2): Retry the
      operation if the table was rebuilt.
      (st_general_delete, st_shift, st_update, st_general_foreach):
      (st_rehash_linear, st_rehash_indexed): Use DO_PTR_EQUAL_CHECK.
      Return the rebuild flag.
      (st_rehash): Retry the operation if the table was rebuilt.
      [ruby-core:85510] [Ruby trunk Bug#14357]
    Thanks to Vit Ondruch for reporting the bug.
    From: Vladimir Makarov <vmakarov at redhat.com>

  Modified directories:
  Modified files:

More information about the ruby-cvs mailing list