summaryrefslogtreecommitdiff
path: root/gc.c
Commit message (Collapse)AuthorAgeFilesLines
* avoid passing NULL to memsetUrabe, Shyouhei2019-04-291-8/+6
| | | | | | | | | `GC::Profiler.enable; GC::Profiler.clear` tries to clear objspace->profile.records but it has never been allocated before. Thus the MEMCPY took NULL argument before this changeset. The objspace->profile.records is allocated appropriately elsewhere. Why not juts free it if any? That should work.
* zero-fill before GC markUrabe, Shyouhei2019-04-261-0/+1
| | | | | | Depending on architectures, setjmp might not fully fill a jmp_buf. On such machines the union can contain wobbly bits. They are then scanned during mark_locations_array(). This is bad.
* disable assertion when MSAN is activeUrabe, Shyouhei2019-04-261-0/+2
| | | | | | | | These assertions check if a newly allocated object (which is marked as an uninitialized memory region in MSAN) is in fact a T_NONE. Thus they intentionally read uninitialized memory regions, which do not interface well with MSAN. Just disalbe them.
* Defer setting gc_stress instead of setting dont_gcNobuyoshi Nakada2019-04-241-5/+1
| | | | [Bug #15784]
* Defer setting gc_stress until inits doneNobuyoshi Nakada2019-04-241-0/+10
| | | | [Bug #15784]
* Oops, bad merge 🙇‍♂️Aaron Patterson2019-04-221-1/+0
|
* Prevent rb_define_(class|module) classes from movingAaron Patterson2019-04-221-1/+1
| | | | | | | | | | | | Before this commit, classes and modules would be registered with the VM's `defined_module_hash`. The key was the ID of the class, but that meant that it was possible for hash collisions to occur. The compactor doesn't allow classes in the `defined_module_hash` to move, but if there is a conflict, then it's possible a class would be removed from the hash and not get pined. This commit changes the key / value of the hash just to be the class itself, thus preventing movement.
* Remove redundant castkazu2019-04-211-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Make sure the has_remembered_objects flag is correctly settenderlove2019-04-201-4/+7
| | | | | | | Remembered objects can move between pages, so we need to make sure the flags on the page are set correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Always pin stack zombie and moved slotstenderlove2019-04-201-0/+5
| | | | | | We should always pin stack zombies and moved git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add `GC.compact` again.tenderlove2019-04-201-33/+1258
| | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Only mark the superclass if there is onetenderlove2019-04-191-2/+6
| | | | | | | Some classes don't have a superclass, so we should check to see if it's there before marking. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-04-171-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting compaction for nowtenderlove2019-04-171-1260/+31
| | | | | | For some reason symbols (or classes) are being overridden in trunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-04-171-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Super should be marked regardless of whether or not ext existstenderlove2019-04-171-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* update super even if there is no exttenderlove2019-04-171-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make verification more stricttenderlove2019-04-171-8/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-04-171-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-171-31/+1248
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adjusted stylesnobu2019-04-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-04-101-47/+47
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-1249/+59
| | | | | | | | Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adjusted stylesnobu2019-04-101-36/+54
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Pin weakmap referencestenderlove2019-04-091-0/+14
| | | | | | | | Weak map references can't move because the st_table needs their address as a key. But, we also need to remove T_NONE from the map so they aren't reused. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-091-58/+1216
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c: missing breaknobu2019-04-071-0/+1
| | | | | | | * gc.c (obj_memsize_of): T_RATIONAL and T_COMPLEX cannot be an imemo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix more ASAN errorstenderlove2019-04-021-3/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Extract type to sym as a new functiontenderlove2019-04-021-31/+37
| | | | | | I will use this from another function in compaction git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix ASAN errortenderlove2019-04-021-1/+1
| | | | | | This code was trying to access memory before unpoisoning it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Poison / verify the freelisttenderlove2019-04-021-1/+33
| | | | | | | | This commit just adds poisoning around the freelist to help debugging. Also verify that the freelist only contains T_NONE objects when checking the heap integrity git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix ASAN errors when walking the heaptenderlove2019-04-011-1/+20
| | | | | | | | | verify_internal_consistency_i and gc_verify_heap_page would walk the heap, reading data from each slot, but would not unpoison the object before reading. This commit unpoisons the slot before reading so that we won't get ASAN errors git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] fix markups [ci skip]nobu2019-03-221-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Early return in gc_mark_childrennobu2019-03-091-5/+7
| | | | | | | | | | | for types Float, Bignum and Symbol as they do not have references and singleton classes. [Fix GH-2091] From: Lourens Naudé <lourens@bearmetal.eu> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Assert that union sizes match"naruse2019-02-161-2/+0
| | | | | | | | | This reverts commit r67078. It breaks armv7l-linux-eabihf and sparc-solaris2.11. http://rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20190215T061708Z.diff.html.gz http://rubyci.s3.amazonaws.com/unstable11s/ruby-trunk/log/20190215T072546Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Assert that union sizes matchnobu2019-02-151-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix empty Hash memsize.ko12019-02-121-2/+4
| | | | | | | * gc.c (obj_memsize_of): ar_table ptr can be NULL (size == 0). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hide ar_table internals from internal.h.ko12018-12-291-2/+3
| | | | | | | | | | | * internal.h: move ar_table def to hash.c because other files don't need to know implementation of ar_table. * hash.c (rb_hash_ar_table_size): added because gc.c needs to know the size_of(ar_table). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move checking code.ko12018-12-231-1/+1
| | | | | | | | | | | | * gc.c (gc_mark_ptr): this check was introduced by accidentaly (this is why message is "...", crazy simple) for debugging. However, this check is useful because if there is T_NONE object here, we can't know which object points to it. For debugging reason, I remain this checking code and set reasonable error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-12-181-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_raw_obj_info() support T_MODULE and T_ICLASS.ko12018-12-181-7/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename li_table->ar_table (and related names).ko12018-12-141-10/+10
| | | | | | | | | | | | | | | | | | | * internal.h: rename the following names: * li_table -> ar_table. "li" means linear (from linear search), but we use the word "array" (from data layout). * RHASH_ARRAY -> RHASH_AR_TABLE. AR_TABLE is more clear. * rb_hash_array_* -> rb_hash_ar_table_*. * RHASH_TABLE_P() -> RHASH_ST_TABLE_P(). more clear. * RHASH_CLEAR() -> RHASH_ST_CLEAR(). * hash.c: rename "linear_" prefix functions to "ar_" prefix. * hash.c (linear_init_table): rename to ar_alloc_table. * debug_counter.h: rename obj_hash_array to obj_hash_ar. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer rb_check_arity when 0 or 1 argumentsnobu2018-12-061-20/+11
| | | | | | | Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove HEAP_ALIGN_LOG setting in configure.ac for OpenBSD/MirOSshyouhei2018-11-291-2/+0
| | | | | | | | | | | | | | | | The ruby setting was renamed to HEAP_PAGE_ALIGN_LOG, but the configure.in (now configure.ac) file was not updated, so the setting had no effect. The configure setting is unnecessary after OpenBSD 5.2 and MirOS has been discontinued (with the last release being over 10 years ago), so it is better to just remove the related configure setting. Fix [Bug #13438] From: Jeremy Evans <code@jeremyevans.net> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-11-261-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Support targetting TracePoint [Feature #15289]ko12018-11-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_trace.c (rb_tracepoint_enable_for_target): support targetting TracePoint. [Feature #15289] Tragetting TracePoint is only enabled on specified method, proc and so on, example: `tp.enable(target: code)`. `code` should be consisted of InstructionSeuqnece (iseq) (RubyVM::InstructionSeuqnece.of(code) should not return nil) If code is a tree of iseq, TracePoint is enabled on all of iseqs in a tree. Enabled tragetting TracePoints can not enabled again with and without target. * vm_core.h (rb_iseq_t): introduce `rb_iseq_t::local_hooks` to store local hooks. `rb_iseq_t::aux::trace_events` is renamed to `global_trace_events` to contrast with `local_hooks`. * vm_core.h (rb_hook_list_t): add `rb_hook_list_t::running` to represent how many Threads/Fibers are used this list. If this field is 0, nobody using this hooks and we can delete it. This is why we can remove code from cont.c. * vm_core.h (rb_vm_t): because of above change, we can eliminate `rb_vm_t::trace_running` field. Also renamed from `rb_vm_t::event_hooks` to `global_hooks`. * vm_core.h, vm.c (ruby_vm_event_enabled_global_flags): renamed from `ruby_vm_event_enabled_flags. * vm_core.h, vm.c (ruby_vm_event_local_num): added to count enabled targetting TracePoints. * vm_core.h, vm_trace.c (rb_exec_event_hooks): accepts hook list. * vm_core.h (rb_vm_global_hooks): added for convinience. * method.h (rb_method_bmethod_t): added to maintain Proc and `rb_hook_list_t` for bmethod (defined by define_method). * prelude.rb (TracePoint#enable): extracet a keyword parameter (because it is easy than writing in C). It calls `TracePoint#__enable` internal method written in C. * vm_insnhelper.c (vm_trace): check also iseq->local_hooks. * vm.c (invoke_bmethod): check def->body.bmethod.hooks. * vm.c (hook_before_rewind): check iseq->local_hooks and def->body.bmethod.hooks before rewind by exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-11-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c: avoid integer overflow at process exitshyouhei2018-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is rather nitpicking but at the moment the process terminates, heap_pages_final_slots overflows. (lldb) bt * thread #1: tid = 0xc0903, 0x00000001002b3bf7 miniruby`finalize_list(objspace=0x0000000101c09240, zombie=4329149840) + 999 at gc.c:2946, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) * frame #0: 0x00000001002b3bf7 miniruby`finalize_list(objspace=0x0000000101c09240, zombie=4329149840) + 999 at gc.c:2946 frame #1: 0x000000010026a69e miniruby`rb_objspace_call_finalizer(objspace=0x0000000101c09240) + 7118 at gc.c:3092 frame #2: 0x0000000100268ac5 miniruby`rb_gc_call_finalizer_at_exit + 149 at gc.c:3015 frame #3: 0x00000001002272bc miniruby`ruby_finalize_1 + 156 at eval.c:146 frame #4: 0x00000001002282b6 miniruby`ruby_cleanup(ex=0) + 4070 at eval.c:238 frame #5: 0x0000000100228785 miniruby`ruby_run_node(n=0x0000000102060ad8) + 85 at eval.c:317 frame #6: 0x0000000100000b9c miniruby`main(argc=2, argv=0x00007fff5fbfdc38) + 124 at main.c:42 frame #7: 0x00007fff9966a5ad libdyld.dylib`start + 1 frame #8: 0x00007fff9966a5ad libdyld.dylib`start + 1 (lldb) p objspace->heap_pages (rb_objspace::(anonymous struct)) $0 = { sorted = 0x0000000101c070b0 allocated_pages = 24 allocatable_pages = 0 sorted_length = 24 range = { [0] = 0x0000000102020028 [1] = 0x00000001020dbfd0 } freeable_pages = 0 final_slots = 0 deferred_final = 4329149840 } (lldb) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* suppress GCC warning about unknown sanitizersshyouhei2018-11-071-3/+1
| | | | | | | See also: https://travis-ci.org/ruby/ruby/jobs/451710726#L1941 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* adopt sanitizer APIshyouhei2018-11-061-4/+28
| | | | | | | | These APIs are much like <valgrind/memcheck.h>. Use them to fine-grain annotate the usage of our memory. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e