summaryrefslogtreecommitdiff
path: root/test/ruby/test_objectspace.rb
AgeCommit message (Collapse)Author
2024-04-12Refactor how object IDs work for special constsPeter Zhu
We don't need to treat static symbols in any special way since they can't be confused with other special consts or GC managed objects.
2022-11-21Add RVALUE_OVERHEAD and move ractor_belonging_idPeter Zhu
This commit adds RVALUE_OVERHEAD for storing metadata at the end of the slot. This commit moves the ractor_belonging_id in debug builds from the flags to RVALUE_OVERHEAD which frees the 16 bits in the headers for object shapes. Notes: Merged: https://github.com/ruby/ruby/pull/6763
2022-07-20Ensure _id2ref finds symbols with the correct typeDaniel Colson
Prior to this commit it was possible to call `ObjectSpace._id2ref` with an offset static symbol object_id and get back a new, incorrectly tagged symbol: ``` > sensible_sym = ObjectSpace._id2ref(:a.object_id) => :a > nonsense_sym = ObjectSpace._id2ref(:a.object_id + 40) => :a > sensible_sym == nonsense_sym => false ``` `nonsense_sym` ends up tagged with `RUBY_ID_INSTANCE` instead of `RB_ID_LOCAL`. That means we can do silly things like: ``` > foo = Object.new > foo.instance_variable_set(:a, 123) (irb):2:in `instance_variable_set': `a' is not allowed as an instance variable name (NameError) > foo.instance_variable_set(ObjectSpace._id2ref(:a.object_id + 40), 123) => 123 > foo.instance_variables => [:a] ``` This was happening because `get_id_entry` ignores the tag bits when looking up the symbol. So `rb_id2str(symid)` would return a value and then we'd continue on with the nonsense `symid`. This commit prevents the situation by checking that the `symid` actually matches what we get back from `get_id_entry`. Now we get a `RangeError` for the nonsense id: ``` > ObjectSpace._id2ref(:a.object_id) => :a > ObjectSpace._id2ref(:a.object_id + 40) (irb):1:in `_id2ref': 0x000000000013f408 is not symbol id value (RangeError) ``` Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6147
2021-11-02Fix typosNobuyoshi Nakada
2021-08-04Reenable GC at the end of testPeter Zhu
The test disables GC but never reenables it. Before this patch, running all tests would have a peak RSS in the main process of >4GB. After this patch, peak RSS in the main process is <500MB. Notes: Merged: https://github.com/ruby/ruby/pull/4707
2021-07-29Do not check pending interrupts when running finalizersJeremy Evans
This fixes cases where exceptions raised using Thread#raise are swallowed by finalizers and not delivered to the running thread. This could cause issues with finalizers that rely on pending interrupts, but that case is expected to be rarer. Fixes [Bug #13876] Fixes [Bug #15507] Co-authored-by: Koichi Sasada <ko1@atdot.net> Notes: Merged: https://github.com/ruby/ruby/pull/4366
2021-07-23Show exception in finalizer [Feature #17798]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4670
2021-03-24Change heap walking to be safe for object allocationPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/4263
2020-06-16Check argument to ObjectSpace._id2refNobuyoshi Nakada
Ensure that the argument is an Integer or implicitly convert to, before dereferencing as a Bignum. Addressed a regression in b99833baec2. Reported by u75615 at https://hackerone.com/reports/898614
2019-12-23ObjectSpace._id2ref should check liveness.Koichi Sasada
objspace->id_to_obj_tbl can contain died objects because of lazy sweep, so that it should check liveness.
2019-07-04Revert self-referencing finalizer warning [Feature #15974]Nobuyoshi Nakada
It has caused CI failures. * d0cd0866d82a58933e5dccd073c753c0c2ad4eb5 Disable GC during rb_objspace_reachable_object_p * 89cef1c56b3a0f9c5e6ccc22a5044477a4fd16c1 Version guard for [Feature #15974] * 796eeb6339952d92ae1b353d450c7883e589852d. Fix up [Feature #15974] * 928260c2a613bbdd4402c300e0bf86ae7562e52a. Warn in verbose mode on defining a finalizer that captures the object
2019-07-03Fix up [Feature #15974]Nobuyoshi Nakada
* Fixed warning condition * Fixed function signature * Use ident hash
2016-08-09test_objectspace.rb: errors in a finalizernobu
* test/ruby/test_objectspace.rb (test_finalizer_with_super): adjust number of arguments to get rid of errors in a finalizer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-20* vm.c (invoke_bmethod, invoke_block_from_c_0): revert r52104shugo
partially to avoid "self has wrong type to call super in this context" errors. [ruby-core:72724] [Bug #11954] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-22gc.c: do not expose internal singleton classnobu
* gc.c (internal_object_p): should not expose singleton classes without a metaclass. based on patches by ko1 and shugo. [Bug #11740] * class.c (rb_singleton_class_object_p): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-25test_objectspace.rb: missing tests from rubyspecnobu
* test/ruby/test_objectspace.rb (test_each_object): incorporated from rubyspec. * test/ruby/test_objectspace.rb (test_each_object_enumerator): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* gc.c (internal_object_p): Now a singleton classes appear byko1
ObjectSpace.each_object. [Bug #11360] * test/ruby/test_objectspace.rb: add a test about it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-09thread.c: get rid of invalid ID symbolnobu
* eval.c (rb_frame_last_func): return the most recent frame method name. * thread.c (recursive_list_access): use the last method name, instead of the current method name which can be unset in some cases, not to use a symbol by the invalid ID. [ruby-core:66742] [Bug #10579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10gc.c: preserve encodingnobu
* gc.c (should_be_callable): preserve encoding of class name in error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13test/ruby: better assertionsnobu
* test/ruby: use better assertions instead of mere assert. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09test_objectspace.rb: run in separate processnobu
* test/ruby/test_objectspace.rb (TestObjectSpace#test_finalizer): run in separate process so that finalizers run at termination certainly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09gc.c: private callnobu
* gc.c (should_be_callable): allow private call since rb_eval_cmd calls even private methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-20test_objectspace.rb: run test_each_object separatelynobu
* test/ruby/test_objectspace.rb (TestObjectSpace#test_each_object): run separately. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03* test/ruby/test_objectspace.rb: skip RuntimeErrorko1
which says a message "can't modify frozen File". Is that correct behavior? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03* iseq.h: iseq_catch_table_entry::catch_type should beko1
Fixnum because they are pushed into Array in a compiler. [Bug #7502] * test/ruby/test_objectspace.rb: add a test of this issue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-23Clean warnings: unused variables.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-15* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err): newmame
method. * test/ruby/test_argf.rb: use assert_in_out_err instead of EnvUtil.rubyexec. * test/ruby/test_module.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_objectspace.rb: ditto. * test/ruby/test_object.rb: ditto. * test/ruby/test_string.rb: ditto. * test/ruby/test_method.rb: ditto. * test/ruby/test_variable.rb: ditto. * test/ruby/test_io.rb: ditto. * test/ruby/test_rubyoptions.rb: ditto. * test/ruby/test_exception.rb: ditto. * test/ruby/test_class.rb: ditto. * test/ruby/test_thread.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-05* test/ruby/test_gc.rb: add tests to achieve over 90% test coverage ofmame
gc.c. * test/ruby/test_objectspace.rb: ditto. * test/ruby/test_marshal.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-01debug print removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31* gc.c (count_objects): clear given hash.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14* test/ruby/test_objectspace.rb: add a test formame
ObjectSpace.count_objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-16use assert_same instead of assert_equal.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-03-04fix string interpolationakr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-03-04* gc.c (id2ref): fix symbol test.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e