<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/ext/objspace/object_tracing.c, branch v4.0.3</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Fix memory leak in ObjectSpace tracing</title>
<updated>2025-11-11T00:34:00+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-11-10T23:08:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=87493e32ed822b78f1294c3c7a11f710ebdb6a90'/>
<id>87493e32ed822b78f1294c3c7a11f710ebdb6a90</id>
<content type='text'>
allocation_info_tracer_compact_update_object_table_i deletes entries where
the key is no longer in the GC heap but did not free the allocation_info
causing the memory to be leaked.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
allocation_info_tracer_compact_update_object_table_i deletes entries where
the key is no longer in the GC heap but did not free the allocation_info
causing the memory to be leaked.
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] ObjectSpace.trace_object_allocations_debug_start</title>
<updated>2025-11-09T13:11:40+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-11-09T12:13:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=87c39667bf881527d4ddfe1c558fc98adb9543a0'/>
<id>87c39667bf881527d4ddfe1c558fc98adb9543a0</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>use `st_update` to prevent table extension</title>
<updated>2024-12-23T02:05:34+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2024-12-20T08:42:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c695536cc8ea4be69849394b0c64c974d52c603a'/>
<id>c695536cc8ea4be69849394b0c64c974d52c603a</id>
<content type='text'>
to prevent the following scenario:

1. `delete_unique_str()` can be called while GC (sweeping)
2. it calls `st_insert()` to decrement the counter
3. `st_insert()` can try to extend the table even if the key exists
4. `xmalloc` while GC and cause BUG
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
to prevent the following scenario:

1. `delete_unique_str()` can be called while GC (sweeping)
2. it calls `st_insert()` to decrement the counter
3. `st_insert()` can try to extend the table even if the key exists
4. `xmalloc` while GC and cause BUG
</pre>
</div>
</content>
</entry>
<entry>
<title>Check whether object is valid in allocation_info_tracer_compact</title>
<updated>2024-12-16T17:24:24+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-12-16T16:41:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=516a6cd1ad620b880651c1333bd856a9d7dec3c4'/>
<id>516a6cd1ad620b880651c1333bd856a9d7dec3c4</id>
<content type='text'>
When reference updating ObjectSpace.trace_object_allocations, we need to
check whether the object is valid or not because it does not mark the
object so the object may be dead. This can cause a segmentation fault
if the object is on a free heap page.

For example, the following script crashes:

    require "objspace"

    objs = []
    ObjectSpace.trace_object_allocations do
      1_000_000.times do
        objs &lt;&lt; Object.new
      end
    end

    objs = nil

    # Free pages that the objs were on
    GC.start

    # Run compaction and check that it doesn't crash
    GC.compact
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When reference updating ObjectSpace.trace_object_allocations, we need to
check whether the object is valid or not because it does not mark the
object so the object may be dead. This can cause a segmentation fault
if the object is on a free heap page.

For example, the following script crashes:

    require "objspace"

    objs = []
    ObjectSpace.trace_object_allocations do
      1_000_000.times do
        objs &lt;&lt; Object.new
      end
    end

    objs = nil

    # Free pages that the objs were on
    GC.start

    # Run compaction and check that it doesn't crash
    GC.compact
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix ObjectSpace.trace_object_allocations for compaction</title>
<updated>2024-12-16T15:12:54+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-12-13T17:20:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=15765eac0ae156afe69b53ab317c4096f2c2c0ec'/>
<id>15765eac0ae156afe69b53ab317c4096f2c2c0ec</id>
<content type='text'>
We need to reinsert into the ST table when an object moves because it is
a numtable that hashes on the object address, so when an object moves we
need to reinsert it rather than just updating the key.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We need to reinsert into the ST table when an object moves because it is
a numtable that hashes on the object address, so when an object moves we
need to reinsert it rather than just updating the key.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix compaction check for ObjectSpace.trace_object_allocations</title>
<updated>2024-12-16T15:12:54+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-12-13T17:20:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b0385305060e6edf98f92993f3f13c5e6a978b0e'/>
<id>b0385305060e6edf98f92993f3f13c5e6a978b0e</id>
<content type='text'>
We should be checking for key for moved objects rather than the value
because the key is a Ruby object and the value is malloc'd memory.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We should be checking for key for moved objects rather than the value
because the key is a Ruby object and the value is malloc'd memory.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge gc.h and internal/gc.h</title>
<updated>2023-02-09T15:32:29+00:00</updated>
<author>
<name>Matt Valentine-House</name>
<email>matt@eightbitraptor.com</email>
</author>
<published>2023-02-08T11:56:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=72aba64fff09a829bfaf41165d0075066f087185'/>
<id>72aba64fff09a829bfaf41165d0075066f087185</id>
<content type='text'>
[Feature #19425]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Feature #19425]
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix crash in tracing object allocations</title>
<updated>2023-01-04T14:10:58+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-01-03T15:59:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b8a3f1bd456f92866c4a7bd83235f78c574784a8'/>
<id>b8a3f1bd456f92866c4a7bd83235f78c574784a8</id>
<content type='text'>
ObjectSpace.trace_object_allocations_start could crash since it adds a
TracePoint for when objects are freed. However, TracePoint could crash
since it modifies st tables while inside the GC that is trying to free
the object. This could cause a memory allocation to happen which would
crash if it triggers another GC.

See a crash log: http://ci.rvm.jp/results/trunk@ruby-sp1/4373707
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ObjectSpace.trace_object_allocations_start could crash since it adds a
TracePoint for when objects are freed. However, TracePoint could crash
since it modifies st tables while inside the GC that is trying to free
the object. This could cause a memory allocation to happen which would
crash if it triggers another GC.

See a crash log: http://ci.rvm.jp/results/trunk@ruby-sp1/4373707
</pre>
</div>
</content>
</entry>
<entry>
<title>Expand tabs [ci skip]</title>
<updated>2022-07-21T16:42:04+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-07-21T16:23:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5b21e94bebed90180d8ff63dad03b8b948361089'/>
<id>5b21e94bebed90180d8ff63dad03b8b948361089</id>
<content type='text'>
[Misc #18891]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Misc #18891]
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #18382] Fix crash in compaction for ObjectSpace.trace_object_allocations</title>
<updated>2021-12-02T18:06:44+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2021-12-02T16:16:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9f0c6f20c58067923864575b60af730d191b8f6c'/>
<id>9f0c6f20c58067923864575b60af730d191b8f6c</id>
<content type='text'>
ObjectSpace.trace_object_allocations can crash when auto-compaction is
enabled.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ObjectSpace.trace_object_allocations can crash when auto-compaction is
enabled.
</pre>
</div>
</content>
</entry>
</feed>
