https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112022-01-26T14:30:44ZRuby Issue Tracking SystemRuby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=961522022-01-26T14:30:44Zibylich (Ilya Bylich)ibylich@gmail.com
<ul></ul><p>As <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/4">@nobu (Nobuyoshi Nakada)</a> mentioned the following code gives no warnings (in verbose mode):</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">A</span>
<span class="k">def</span> <span class="nf">foo</span><span class="p">;</span> <span class="k">end</span>
<span class="k">alias</span> <span class="n">foo</span> <span class="n">foo</span><span class="p">;</span>
<span class="k">def</span> <span class="nf">foo</span><span class="p">;</span> <span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>but if we stop increment <code>alias_count</code> on <code>alias foo foo</code> the warning appears (because <code>alias foo foo</code> becomes a real noop, with absolutely no side effect).</p> Ruby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=961532022-01-26T15:20:56Zufuk (Ufuk Kayserilioglu)
<ul></ul><p>ibylich (Ilya Bylich) wrote in <a href="#note-1">#note-1</a>:</p>
<blockquote>
<p>but if we stop increment <code>alias_count</code> on <code>alias foo foo</code> the warning appears (because <code>alias foo foo</code> becomes a real noop, with absolutely no side effect).</p>
</blockquote>
<p>Rails heavily depends on this behaviour and if this is changed it will end up raising <strong>a lot</strong> of warnings. I am not even sure if there is another way to replace methods without raising any warnings, if this is taken away.</p> Ruby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=961562022-01-26T15:44:50Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p><a href="https://github.com/ruby/ruby/pull/5493" class="external">https://github.com/ruby/ruby/pull/5493</a></p> Ruby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=961982022-01-27T06:46:47Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="Fix memory leak at the same named alias [Bug #18516] When aliasing a method to the same name met..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/e89d80702bd98a8276243a7fcaa2a158b3bfb659">git|e89d80702bd98a8276243a7fcaa2a158b3bfb659</a>.</p>
<hr>
<p>Fix memory leak at the same named alias [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Memory leak on aliasing method to itself (Closed)" href="https://bugs.ruby-lang.org/issues/18516">#18516</a>]</p>
<p>When aliasing a method to the same name method, set a separate bit<br>
flag on that method definition, instead of the reference count<br>
increment. Although this kind of alias has no actual effect at<br>
runtime, is used as the hack to suppress the method re-definition<br>
warning.</p> Ruby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=961992022-01-27T09:11:21Zbyroot (Jean Boussier)byroot@ruby-lang.org
<ul><li><strong>Backport</strong> changed from <i>2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN</i> to <i>2.6: WONTFIX, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED</i></li></ul><p>I took the liberty to set the backport field.</p>
<p>I was able to repro on 2.6, 2.7,3.0 and 3.1. However 2.6 is security only, I don't think it qualifies.</p> Ruby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=963552022-02-02T23:05:12Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Backport</strong> changed from <i>2.6: WONTFIX, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED</i> to <i>2.6: WONTFIX, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE</i></li></ul><p>ruby_3_1 42c9ef769f210d88241a114395dd5ffc27b2fb87 merged revision(s) 7ff1bf317887c0d7b21e91ad548d07b9f05c540c,e89d80702bd98a8276243a7fcaa2a158b3bfb659.</p> Ruby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=968102022-03-13T03:13:27Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.6: WONTFIX, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE</i> to <i>2.6: WONTFIX, 2.7: REQUIRED, 3.0: DONE, 3.1: DONE</i></li></ul><p>ruby_3_0 6175823bab28b5d12f66371d67d006df37751fbc merged revision(s) 7ff1bf317887c0d7b21e91ad548d07b9f05c540c,e89d80702bd98a8276243a7fcaa2a158b3bfb659.</p> Ruby master - Bug #18516: Memory leak on aliasing method to itselfhttps://bugs.ruby-lang.org/issues/18516?journal_id=971752022-04-07T14:27:48Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Backport</strong> changed from <i>2.6: WONTFIX, 2.7: REQUIRED, 3.0: DONE, 3.1: DONE</i> to <i>2.6: WONTFIX, 2.7: DONE, 3.0: DONE, 3.1: DONE</i></li></ul>