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 * {ext,lib,test}/**/*.rb: removed trailing spaces. 2009-03-06 03:56:38 +00:00
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 supress warnings. 2010-01-25 23:12:50 +00:00
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 * test/gdbm/test_gdbm.rb (TestGDBM#test_s_open_no_create, 2011-01-28 14:23:04 +00:00
iconv * test/iconv/utils.rb: suppress warning message. 2010-11-28 13:25:58 +00:00
io * test/io/console/test_io_console.rb (test_noctty): daemon() on 2011-08-04 22:00:36 +00:00
irb * test/irb/test_option.rb (test_end_of_option): don't read .irbrc. Bug#4138 2010-12-08 22:00:59 +00:00
json * ext/json: Merge json gem 1.5.4+ (f7f78896607b6f6226cd). 2011-07-10 08:01:04 +00:00
logger * remove trailing spaces. 2011-05-15 11:55:52 +00:00
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 * lib/mkmf.rb (find_executable0): should exclude directories. 2011-03-11 09:42:46 +00:00
monitor * lib/monitor.rb (wait): supported timeout. 2010-02-06 12:31:52 +00:00
net * lib/net/imap.rb (idle): raises a Net::IMAP::Error when the 2011-08-19 05:16:20 +00:00
nkf * ext/nkf/lib/kconv.rb (String#kconv): fix typo and update rdoc. 2010-12-07 11:47:39 +00:00
objspace * ext/objspace/objspace.c (ObjectSpace.memsize_of_all): rename 2010-10-28 20:23:21 +00:00
open-uri * remove trailing spaces. 2011-05-15 11:55:52 +00:00
openssl * ext/openssl/ossl_ssl.c: Support disabling OpenSSL compression. 2011-08-15 01:10:26 +00:00
optparse * lib/optparse.rb: shell completion support for zsh. based on 2010-11-19 12:07:09 +00:00
ostruct * lib/ostruct.rb (method_missing): Handle [] and []= correctly. 2011-05-27 15:59:02 +00:00
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 * remove trailing spaces. 2011-05-15 11:55:52 +00:00
resolv * lib/resolv.rb (Resolv::DNS::Requester#request): rescue ECONNREFUSED. 2010-05-29 00:06:17 +00:00
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 * lib/rexml/encoding.rb: use Ruby native encoding mechnism. [ruby-dev:42464] 2010-10-30 12:10:56 +00:00
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 * test/scanf/test_scanf.rb (ScanfTests#each_test): yield in order. 2010-05-13 10:06:25 +00:00
sdbm * test/sdbm/test_sdbm.rb (test_s_open_error): doesn't support to avoid read 2010-05-27 05:47:21 +00:00
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 avoid method redefinition. 2010-02-14 03:09:53 +00:00
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 * remove trailing spaces. 2011-05-15 11:55:52 +00:00
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 property. 2010-10-29 23:50:57 +00:00
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 * object.c (rb_obj_clone): call initialize_clone hook method to 2010-02-08 07:43:54 +00:00
test_find.rb * test/test_find.rb: skip some tests on Windows. 2010-05-25 07:03:31 +00:00
test_ipaddr.rb use require_relative. 2010-02-02 13:58:56 +00:00
test_mathn.rb Clean warnings: unused variables. 2010-06-23 05:32:46 +00:00
test_mutex_m.rb * lib/optparse.rb: suppress a warning. 2010-08-10 12:02:52 +00:00
test_open3.rb * test/test_open3.rb (TestOpen3#test_commandline): use simple 2010-04-30 12:40:40 +00:00
test_pp.rb * lib/pp.rb (PP::ObjectMixin#pretty_print): use to_s regardless of 2009-11-07 12:05:38 +00:00
test_prettyprint.rb wrap by a module. 2009-10-04 05:44:27 +00:00
test_prime.rb * test/syck/test_string.rb (Syck::TestString#test_non_binary_string): 2011-02-13 00:56:44 +00:00
test_pstore.rb * remove trailing spaces. 2011-05-15 11:55:52 +00:00
test_pty.rb * test/test_pty.rb (TestPTY::test_getpty_nonexistent): ditto. 2010-09-24 07:37:26 +00:00
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 use require_relative. 2010-02-02 13:58:56 +00:00
test_shellwords.rb * {ext,lib,test}/**/*.rb: removed trailing spaces. 2009-03-06 03:56:38 +00:00
test_singleton.rb * test/test_singleton.rb: Add tests from lib/singleton.rb. Patch by 2011-05-17 18:15:10 +00:00
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/test_tempfile.rb: simply ignore platform depedent testcases 2011-04-04 02:51:17 +00:00
test_time.rb * strftime.c (rb_strftime_with_timespec): improved style consistency. 2011-05-31 03:59:36 +00:00
test_timeout.rb * lib/timeout.rb (Timeout#timeout): propagate errors to the 2010-04-19 09:58:09 +00:00
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 * test/test_pp.rb: extract from lib/pp.rb. 2009-02-14 23:36:45 +00:00
with_different_ofs.rb * test/with_different_ofs.rb (DifferentOFS): should not affect 2010-12-26 02:15:55 +00:00