1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test
nahi 1e7f99dddf * variable.c: Make autoload thread-safe. See #921.
What's the problem?
    autoload is thread unsafe. When we define a constant to be
    autoloaded, we expect the constant construction is invariant. But
    current autoload implementation allows other threads to access the
    constant while the first thread is loading a file.

  What's happening inside?
    The current implementation uses Qundef as a marker of autoload in
    Constant table. Once the first thread find Qundef as a value at
    constant lookup, it starts loading a defined feature. Generally a
    loaded file overrides the Qundef in Constant table by module/class
    declaration at very beginning lines of the file, so other threads
    can see the new Module/Class object before feature loading is
    finished. It breaks invariant construction.

  How to solve?
    To ensure invariant constant construction, we need to override
    Qundef with defined Object after the feature loading. For keeping
    Qundef in Constant table, I expanded autoload_data struct in
    Module to have a slot for keeping the defined object while feature
    loading. And changed Module's constant lookup/update logic a
    little so that the slot is only visible from the thread which
    invokes feature loading. (== the first thread which accessed the
    autoload constant)

  Evaluation?
    All test passes (bootstrap test, test-all and RubySpec) and added
    8 tests for threading behavior. Extra logics are executed only
    when Qundef is found, so no perf drop should happen except
    autoloading.

* variable.c (rb_autoload): Prepare new autoload_data struct.

* variable.c (rb_autoload_load): Load feature and update Constant
  table after feature loading is finished. 

* variable.c (rb_const_get_0): When the fetched constant is under
  autoloading, it returns the object only for the thread which starts
  autoloading.

* variable.c (rb_const_defined_0): Ditto.

* variable.c (rb_const_set): When the specified constant is under
  autoloading, it sets the object only for the thread which starts
  autoloading. Otherwise, simply overrides Qundef with constant
  override warning.

* vm_insnhelper.c (vm_get_ev_const): Apply same change as
  rb_const_get_0 in variable.c.

* test/ruby/test_autoload.rb: Added tests for threading behavior.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-26 10:27:20 +00:00
..
-ext- * util.c, include/ruby/util.h (ruby_add_suffix): remove the function. 2011-08-03 07:10:56 +00:00
base64
benchmark * lib/benchmark.rb: merge eregon/benchmark. 2011-06-28 06:09:46 +00:00
bigdecimal Merge branch '5172_bigdecimal_gc_issue' into trunk 2011-08-17 06:35:21 +00:00
cgi * lib/cgi/core.rb: fix multipart form parsing bug. [Bug #3866] 2011-07-09 05:32:19 +00:00
coverage * thread.c (update_coverage): skip coverage count up if the current 2011-08-23 15:44:26 +00:00
csv * lib/csv.rb: Do not modify CSV.generate's argument [ruby-core:38356] 2011-07-21 21:37:43 +00:00
date * test/date/test_*.rb: added tests. 2011-08-13 00:41:10 +00:00
dbm
digest * ext/digest/sha2/sha2.c (SHA256_Update, SHA512_Update): avoid Bus 2011-07-15 03:03:31 +00:00
dl * test/fiddle/helper.rb (libc_so, libm_so): Solaris support added. 2011-08-09 03:36:18 +00:00
drb * properties. 2011-06-29 03:35:48 +00:00
erb
etc * test/etc/test_etc.rb (TestEtc#test_get{pw,gr}nam): skip entries 2011-06-26 16:34:20 +00:00
fiddle * test/fiddle/helper.rb (libc_so, libm_so): Solaris support added. 2011-08-09 03:36:18 +00:00
fileutils * test/fileutils/test_fileutils.rb (test_chmod_symbol_mode): Solaris 2011-08-24 16:41:12 +00:00
gdbm
iconv
io * test/io/console/test_io_console.rb (test_noctty): daemon() on 2011-08-04 22:00:36 +00:00
irb
json * ext/json: Merge json gem 1.5.4+ (f7f78896607b6f6226cd). 2011-07-10 08:01:04 +00:00
logger
matrix * test/matrix/test_matrix.rb: remove obsolete test [ruby-core:37714] 2011-07-01 22:25:32 +00:00
minitest Imported minitest 2.5.0 (r6557) 2011-08-23 21:47:25 +00:00
misc Run tests only for emacs 23+. 2011-06-15 03:28:47 +00:00
mkmf
monitor
net * lib/net/imap.rb (idle): raises a Net::IMAP::Error when the 2011-08-19 05:16:20 +00:00
nkf
objspace
open-uri
openssl * ext/openssl/ossl_ssl.c: Support disabling OpenSSL compression. 2011-08-15 01:10:26 +00:00
optparse
ostruct
pathname * test/ruby/test_io.rb (test_copy_stream_socket): wait a child process 2011-06-15 03:36:57 +00:00
psych * ext/psych/lib/psych/nodes/node.rb: default to_yaml encoding to be 2011-08-24 21:14:44 +00:00
rake * lib/rake: Update to Rake 0.9.2.2. Prevent pollution of toplevel 2011-08-12 16:56:48 +00:00
rdoc * lib/rdoc: Update to RDoc 3.9.3. Fixes RDoc with ruby -Ku. Allows 2011-08-23 23:53:49 +00:00
readline
resolv
rexml * lib/rexml/formatters/pretty.rb 2011-06-11 07:29:48 +00:00
rinda the code that depends on timing. [Bug #372] [Bug #4160] 2011-07-28 03:25:55 +00:00
ripper * parse.y (var_ref): distinguish vcall from local variable 2011-07-10 13:38:17 +00:00
rss
ruby * variable.c: Make autoload thread-safe. See #921. 2011-08-26 10:27:20 +00:00
rubygems * lib/rubygems: Update to RubyGems 1.8.10. Fixes security issue in 2011-08-26 01:10:50 +00:00
scanf
sdbm
socket * test/socket/test_socket.rb (test_connect_timeout): added a test 2011-08-13 20:58:11 +00:00
stringio * ext/stringio/stringio.c (strio_read): return new string if nil 2011-08-20 01:43:26 +00:00
strscan
syck Copy YAML::Store to Syck::Store to keep it from yamler. 2011-06-14 01:06:41 +00:00
testunit * test/testunit/test_parallel.rb: pass "--ruby" option to 2011-08-02 11:18:58 +00:00
thread
uri * lib/net/http.rb (URI::HTTP#request_uri): return nil when the uri 2011-06-03 00:32:25 +00:00
webrick * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#each): 2011-07-21 08:27:08 +00:00
win32ole * test/win32ole/test_win32ole_variant.rb: use skip method to skip the test. 2011-07-30 08:36:47 +00:00
xmlrpc * lib/xmlrpc/client.rb, lib/xmlrpc/server.rb: should use 2011-08-05 04:35:28 +00:00
zlib * ext/zlib/zlib.c (gzfile_read_header): Ensure that each section of 2011-08-23 02:36:13 +00:00
inlinetest.rb
profile_test_all.rb
runner.rb * common.mk (RUN_OPT): disable gems. 2011-07-08 23:39:42 +00:00
test_cmath.rb Rerefix test introduced by r32307. 2011-06-30 03:31:01 +00:00
test_delegate.rb
test_find.rb
test_ipaddr.rb
test_mathn.rb
test_mutex_m.rb
test_open3.rb
test_pp.rb
test_prettyprint.rb
test_prime.rb
test_pstore.rb
test_pty.rb
test_securerandom.rb * test/test_securerandom.rb: Add testcase. This testcase does NOT aim 2011-06-16 10:32:51 +00:00
test_set.rb
test_shellwords.rb
test_singleton.rb
test_syslog.rb * test/test_syslog.rb (TestSyslog#test_log): Do not be too 2011-08-05 08:26:42 +00:00
test_tempfile.rb
test_time.rb
test_timeout.rb
test_tracer.rb * lib/tracer.rb: Tracer.on only if required by -r command-line option. 2011-06-29 13:19:59 +00:00
test_tsort.rb
with_different_ofs.rb