<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/transcode.c, branch v4.0.4</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 String#encode when StringValue raises</title>
<updated>2025-11-01T14:47:39+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-10-30T22:18:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=390d77ba00f9e8f18a5408b404365db0b25fbf37'/>
<id>390d77ba00f9e8f18a5408b404365db0b25fbf37</id>
<content type='text'>
The following script leaks memory:

    10.times do
      100_000.times do
        "\ufffd".encode(Encoding::US_ASCII, fallback: proc { Object.new })
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    450244
    887748
    1325124
    1762756
    2200260
    2637508
    3075012
    3512516
    3950020
    4387524

After:

    12236
    12364
    12748
    13004
    13388
    13516
    13772
    13772
    13772
    13772
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following script leaks memory:

    10.times do
      100_000.times do
        "\ufffd".encode(Encoding::US_ASCII, fallback: proc { Object.new })
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    450244
    887748
    1325124
    1762756
    2200260
    2637508
    3075012
    3512516
    3950020
    4387524

After:

    12236
    12364
    12748
    13004
    13388
    13516
    13772
    13772
    13772
    13772
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix memory leak in String#encode when fallback too big</title>
<updated>2025-10-30T00:18:38+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-10-28T23:46:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b8c82a99a03722c4641d5fe41ebd393e0e4806c2'/>
<id>b8c82a99a03722c4641d5fe41ebd393e0e4806c2</id>
<content type='text'>
The following script leaks memory:

    10.times do
      100_000.times do
        "\ufffd".encode(Encoding::US_ASCII, fallback: proc { "\uffee" })
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    451196
    889596
    1328252
    1766524
    2204668
    2643068
    3081724
    3520124
    3958524
    4396796

After:

    12800
    13056
    13184
    13312
    13312
    13312
    13312
    13312
    13312
    13312
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following script leaks memory:

    10.times do
      100_000.times do
        "\ufffd".encode(Encoding::US_ASCII, fallback: proc { "\uffee" })
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    451196
    889596
    1328252
    1766524
    2204668
    2643068
    3081724
    3520124
    3958524
    4396796

After:

    12800
    13056
    13184
    13312
    13312
    13312
    13312
    13312
    13312
    13312
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix memory leak of transcoding when fallback raises</title>
<updated>2025-10-24T22:34:13+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-10-22T23:47:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cb302881629f997f403e705425f69e5f6b0741ac'/>
<id>cb302881629f997f403e705425f69e5f6b0741ac</id>
<content type='text'>
When the fallback function in transcode_loop raises, it will leak the memory
in rb_econv_t. The following script reproduces the leak:

    10.times do
      100_000.times do
        "\ufffd".encode(Encoding::US_ASCII, fallback: proc { raise })
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    451196
    889980
    1328508
    1767676
    2206460
    2645372
    3083900
    3522428
    3960956
    4399484

After:

    12508
    12636
    12892
    12892
    13148
    13404
    13532
    13788
    13916
    13916
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the fallback function in transcode_loop raises, it will leak the memory
in rb_econv_t. The following script reproduces the leak:

    10.times do
      100_000.times do
        "\ufffd".encode(Encoding::US_ASCII, fallback: proc { raise })
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    451196
    889980
    1328508
    1767676
    2206460
    2645372
    3083900
    3522428
    3960956
    4399484

After:

    12508
    12636
    12892
    12892
    13148
    13404
    13532
    13788
    13916
    13916
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixes to encoding/transcoding for ractors.</title>
<updated>2025-08-22T17:49:44+00:00</updated>
<author>
<name>Luke Gruber</name>
<email>luke.gruber@shopify.com</email>
</author>
<published>2025-08-14T23:21:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9db54a1a98956ea37a04d6e3f83fcd6745ed96a6'/>
<id>9db54a1a98956ea37a04d6e3f83fcd6745ed96a6</id>
<content type='text'>
Not all ractor-related encoding issues were fixed by 1afc07e815051e2f73493f055f2130cb642ba12a.
I found more by running my test-all branch with 3 ractors for each test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Not all ractor-related encoding issues were fixed by 1afc07e815051e2f73493f055f2130cb642ba12a.
I found more by running my test-all branch with 3 ractors for each test.
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow encodings to be autoloaded through transcoding functions</title>
<updated>2025-08-12T22:19:02+00:00</updated>
<author>
<name>Luke Gruber</name>
<email>luke.gruber@shopify.com</email>
</author>
<published>2025-08-06T18:30:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1afc07e815051e2f73493f055f2130cb642ba12a'/>
<id>1afc07e815051e2f73493f055f2130cb642ba12a</id>
<content type='text'>
Make sure VM lock is not held when calling `load_transcoder_entry`, as
that causes deadlock inside ractors. `String#encode` now works inside
ractors, among others.

Atomic load the rb_encoding_list

Without this, wbcheck would sometimes hit a missing write barrier.

Co-authored-by: John Hawthorn &lt;john.hawthorn@shopify.com&gt;

Hold VM lock when iterating over global_enc_table.names

This st_table can be inserted into at runtime when autoloading
encodings.

minor optimization when calling Encoding.list
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Make sure VM lock is not held when calling `load_transcoder_entry`, as
that causes deadlock inside ractors. `String#encode` now works inside
ractors, among others.

Atomic load the rb_encoding_list

Without this, wbcheck would sometimes hit a missing write barrier.

Co-authored-by: John Hawthorn &lt;john.hawthorn@shopify.com&gt;

Hold VM lock when iterating over global_enc_table.names

This st_table can be inserted into at runtime when autoloading
encodings.

minor optimization when calling Encoding.list
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Tweak for String#encode!</title>
<updated>2025-07-24T19:57:28+00:00</updated>
<author>
<name>BurdetteLamar</name>
<email>burdettelamar@yahoo.com</email>
</author>
<published>2025-07-23T20:40:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ed22e15acb83562825a6b4cd95a8ae15c0d3b6d2'/>
<id>ed22e15acb83562825a6b4cd95a8ae15c0d3b6d2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Get transcoding to work across ractors by locking certain operations</title>
<updated>2025-07-03T20:20:34+00:00</updated>
<author>
<name>Luke Gruber</name>
<email>luke.gruber@shopify.com</email>
</author>
<published>2025-06-12T19:13:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4f4408e98933f65f9d5b1752c2892218f2224de3'/>
<id>4f4408e98933f65f9d5b1752c2892218f2224de3</id>
<content type='text'>
Ex: `str.encode` and `str.encode!` work across ractors now.

The global table `transcoder_table` needs a lock around each st_lookup/st_insert, and it's a two-level
table so the second level also needs to be locked around insertion/deletion. In addition to this, the
transcoder entries (values in the second-level hash table) need to be locked around retrieving them and
loading them as they are loaded lazily.

The transcoding objects (`Encoding::Converter`) can't be made shareable, so their operations don't need to be locked.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Ex: `str.encode` and `str.encode!` work across ractors now.

The global table `transcoder_table` needs a lock around each st_lookup/st_insert, and it's a two-level
table so the second level also needs to be locked around insertion/deletion. In addition to this, the
transcoder entries (values in the second-level hash table) need to be locked around retrieving them and
loading them as they are loaded lazily.

The transcoding objects (`Encoding::Converter`) can't be made shareable, so their operations don't need to be locked.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix constant documents (#12357)</title>
<updated>2024-12-17T02:58:00+00:00</updated>
<author>
<name>Soutaro Matsumoto</name>
<email>matsumoto@soutaro.com</email>
</author>
<published>2024-12-17T02:58:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c7a638747ae4c2cf7eee17b07e782b1ee446ec82'/>
<id>c7a638747ae4c2cf7eee17b07e782b1ee446ec82</id>
<content type='text'>
Delete duplicated `Document-const:` directives

Those directives are attached to `rb_define_const` and `rb_file_const` where we don’t need them because the functions are supported by RDoc.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Delete duplicated `Document-const:` directives

Those directives are attached to `rb_define_const` and `rb_file_const` where we don’t need them because the functions are supported by RDoc.</pre>
</div>
</content>
</entry>
<entry>
<title>Free everything at shutdown</title>
<updated>2023-12-07T20:52:35+00:00</updated>
<author>
<name>Adam Hess</name>
<email>adamhess1991@gmail.com</email>
</author>
<published>2023-10-12T18:15:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6816e8efcff3be75f8020cd1b0ea57d3cd664bbc'/>
<id>6816e8efcff3be75f8020cd1b0ea57d3cd664bbc</id>
<content type='text'>
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown.

Co-authored-by: Nobuyoshi Nakada &lt;nobu@ruby-lang.org&gt;
Co-authored-by: Peter Zhu &lt;peter@peterzhu.ca&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown.

Co-authored-by: Nobuyoshi Nakada &lt;nobu@ruby-lang.org&gt;
Co-authored-by: Peter Zhu &lt;peter@peterzhu.ca&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Adjust indent [ci skip]</title>
<updated>2023-10-27T08:01:44+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-03-23T15:04:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9c5b084c0a7ff6e156b7f9d5789f80cd62a06af1'/>
<id>9c5b084c0a7ff6e156b7f9d5789f80cd62a06af1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
