<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/ext/objspace/object_tracing.c, branch v3_4_9</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<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>
<entry>
<title>Fix ObjectSpace.trace_object_allocations_stop to not raise if the tracepoint were not initialized</title>
<updated>2020-08-19T15:13:09+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2020-04-03T13:28:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a74df67244199d1fd1f7a20b49dd5a096d2a13a2'/>
<id>a74df67244199d1fd1f7a20b49dd5a096d2a13a2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Update references when tracing allocations</title>
<updated>2020-08-19T02:10:51+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2020-08-19T00:34:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7a58ee9b962ad0072e5213d3512c809048e4eba1'/>
<id>7a58ee9b962ad0072e5213d3512c809048e4eba1</id>
<content type='text'>
The allocation tracing code keeps essentially a weak reference to
objects that have been allocated (storing the allocation information
along with the weak ref).  Compacting the heap would break references in
this weak map, so the wrong values could be returned.

This commit just updates the values in the weak ref in order to fix the
allocation tracing book keeping
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The allocation tracing code keeps essentially a weak reference to
objects that have been allocated (storing the allocation information
along with the weak ref).  Compacting the heap would break references in
this weak map, so the wrong values could be returned.

This commit just updates the values in the weak ref in order to fix the
allocation tracing book keeping
</pre>
</div>
</content>
</entry>
</feed>
