Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112017-12-25T21:38:04ZRuby Issue Tracking System
Redmine Ruby master - Bug #14233 (Rejected): syntax error caused by paren-less method call with kwargs an...https://redmine.ruby-lang.org/issues/142332017-12-25T21:38:04Zcremno (cremno phobia)
<p>Example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="mi">3</span><span class="p">.</span><span class="nf">step</span> <span class="ss">by: </span><span class="mi">3</span><span class="p">,</span> <span class="ss">to: </span><span class="mi">9</span> <span class="p">{</span><span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="nb">p</span> <span class="n">i</span><span class="p">}</span>
</code></pre>
<p>Expected result (before 2.5.0):</p>
<pre><code>3
6
9
</code></pre>
<p>Actual result (2.5.0):</p>
<pre><code>a.rb:1: syntax error, unexpected '{', expecting end-of-input
3.step by: 3, to: 9 {|i| p i}
^
</code></pre> Ruby master - Bug #12340 (Closed): Windows: File.truncate has two string encoding issueshttps://redmine.ruby-lang.org/issues/123402016-05-02T12:47:26Zcremno (cremno phobia)
<p><code>File.truncate</code> calls <code>rb_str_encode_ospath()</code> which returns a UTF-8 encoded Ruby string.<br>
Then it passes a pointer to the underlying C string to <code>truncate()</code> aka <code>rb_w32_truncate()</code>.<br>
At last the UTF-8 string is passed to <code>CreateFile()</code> aka <code>CreateFileA()</code> (ANSI).</p>
<p>This also means it doesn't support Unicode unlike (hopefully all) other File singleton methods.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">s</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\u</span><span class="s2">2603"</span>
<span class="no">IO</span><span class="p">.</span><span class="nf">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s1">'123'</span><span class="p">)</span>
<span class="no">File</span><span class="p">.</span><span class="nf">truncate</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="c1"># Errno::ENOENT: No such file or directory @ rb_file_s_truncate - ☃</span>
</code></pre>
<p>A possible fix is attached. I'm not sure about the test code. I also couldn't find any similar tests. The actual fix should be fine however.</p> Ruby master - Bug #12279 (Closed): cont.c: wrong _MSC_VER checkhttps://redmine.ruby-lang.org/issues/122792016-04-13T19:17:09Zcremno (cremno phobia)
<p>2.3.0 and trunk are affected. I wonder why compiling with Visual C++ 6.0 is still supported.</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/cont.c b/cont.c
index 8ebd78f..729a025 100644
</span><span class="gd">--- a/cont.c
</span><span class="gi">+++ b/cont.c
</span><span class="p">@@ -657,7 +657,7 @@</span> fiber_initialize_machine_stack_context(rb_fiber_t *fib, size_t size)
rb_thread_t *sth = &fib->cont.saved_thread;
#ifdef _WIN32
<span class="gd">-# if defined(_MSC_VER) && _MSC_VER <= 0x1200
</span><span class="gi">+# if defined(_MSC_VER) && _MSC_VER <= 1200
</span> # define CreateFiberEx(cs, stacksize, flags, entry, param) \
CreateFiber((stacksize), (entry), (param))
# endif
<span class="err">
</span></code></pre> Ruby master - Feature #12205 (Closed): update missing/strl{cat,cpy}.chttps://redmine.ruby-lang.org/issues/122052016-03-22T11:43:56Zcremno (cremno phobia)
<p>The attached git diff updates <code>missing/strlcat.c</code> from 1.8 to 1.15,<br>
<code>missing/strlcpy.c</code> from 1.5 to 1.12 and also the <code>LEGAL</code> file.</p>
<p>There is no important reason. But there was a license change:<br>
new style-BSD to a less restrictive ISC-style license.</p>
<p>Other changes include improving code readability and<br>
modernizing (function prototypes, no <code>register</code>)</p>
<p>Upstream URLs (if you're looking for more details):<br>
<a href="http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcat.c" class="external">http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcat.c</a><br>
<a href="http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcpy.c" class="external">http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcpy.c</a></p> Ruby master - Bug #11579 (Closed): Fiddle.win32_last_error after calling Fiddle::Function#call is...https://redmine.ruby-lang.org/issues/115792015-10-10T11:42:03Zcremno (cremno phobia)
<p>The current source code is:</p>
<pre><code class="c syntaxhl" data-language="c"> <span class="n">rb_funcall</span><span class="p">(</span><span class="n">mFiddle</span><span class="p">,</span> <span class="n">rb_intern</span><span class="p">(</span><span class="s">"last_error="</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">INT2NUM</span><span class="p">(</span><span class="n">errno</span><span class="p">));</span>
<span class="cp">#if defined(_WIN32)
</span> <span class="n">rb_funcall</span><span class="p">(</span><span class="n">mFiddle</span><span class="p">,</span> <span class="n">rb_intern</span><span class="p">(</span><span class="s">"win32_last_error="</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">INT2NUM</span><span class="p">(</span><span class="n">errno</span><span class="p">));</span>
<span class="cp">#endif
</span></code></pre>
<p>I guess this is a copy-and-paste mistake and not the intended behavior. The attached patch is untested.</p> Ruby master - Bug #11320 (Closed): reopening stdio streams with non-ANSI filenames fails on Windowshttps://redmine.ruby-lang.org/issues/113202015-06-29T23:12:25Zcremno (cremno phobia)
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">fname</span> <span class="o">=</span> <span class="s1">'ルビー'</span>
<span class="no">File</span><span class="p">.</span><span class="nf">write</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="s1">''</span><span class="p">)</span>
<span class="nb">p</span> <span class="no">File</span><span class="p">.</span><span class="nf">exist?</span><span class="p">(</span><span class="n">fname</span><span class="p">)</span>
<span class="vg">$stdin</span><span class="p">.</span><span class="nf">reopen</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="s1">'r'</span><span class="p">)</span>
</code></pre>
<p>It fails with <code>Errno::ENOENT</code> on Windows even though the file exists and is readable. It's caused by using <code>freopen()</code> (<a href="https://github.com/ruby/ruby/blob/v2_2_2/io.c#L6765" class="external">https://github.com/ruby/ruby/blob/v2_2_2/io.c#L6765</a>). A wrapper that converts to UTF-16LE and then calls <code>wfreopen()</code> has to be added to <code>win32/win32.c</code>.</p> Ruby master - Bug #11319 (Closed): "w+" is interpreted as "r+" when reopening stdio streamshttps://redmine.ruby-lang.org/issues/113192015-06-29T22:55:44Zcremno (cremno phobia)
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/io.c b/io.c
index dfdb422..8358c74 100644
</span><span class="gd">--- a/io.c
</span><span class="gi">+++ b/io.c
</span><span class="p">@@ -5046,6 +5046,9 @@</span> rb_io_oflags_modestr(int oflags)
case O_WRONLY:
return MODE_BINARY("w", "wb");
case O_RDWR:
<span class="gi">+ if (oflags & O_TRUNC) {
+ return MODE_BINARY("w+", "wb+");
+ }
</span> return MODE_BINARY("r+", "rb+");
}
}
<span class="gh">diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 9b3e801..1662ac0 100644
</span><span class="gd">--- a/test/ruby/test_io.rb
</span><span class="gi">+++ b/test/ruby/test_io.rb
</span><span class="p">@@ -2069,6 +2069,15 @@</span> End
}
end
<span class="gi">+ def test_reopen_stdio
+ mkcdtmpdir {
+ fname = 'bug11319'
+ File.write(fname, 'hello')
+ system(EnvUtil.rubybin, '-e', "STDOUT.reopen('#{fname}', 'w+')")
+ assert_equal('', File.read(fname))
+ }
+ end
+
</span> def test_reopen_mode
feature7067 = '<a href="/issues/7067">[ruby-core:47694]</a>'
make_tempfile {|t|
<span class="err">
</span></code></pre> Ruby master - Feature #11258 (Closed): add 'x' mode character for O_EXCLhttps://redmine.ruby-lang.org/issues/112582015-06-13T13:06:28Zcremno (cremno phobia)
<p>I just saw <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: rb_io_modestr_oflags for Ruby API (Closed)" href="https://redmine.ruby-lang.org/issues/11253">#11253</a> which contains:</p>
<blockquote>
<p>But some modes has only integer form like O_CLOEXEC, O_EXCL.</p>
</blockquote>
<p>However C11 added <code>x</code> to open a file for exclusive access. It's also supported by Python.</p>
<p><a href="http://port70.net/~nsz/c/c11/n1570.html#7.21.5.3p5" class="external">http://port70.net/~nsz/c/c11/n1570.html#7.21.5.3p5</a><br>
<a href="https://docs.python.org/3.3/library/functions.html#open" class="external">https://docs.python.org/3.3/library/functions.html#open</a></p> Ruby master - Bug #11192 (Closed): capture group special variable with large index invokes UBhttps://redmine.ruby-lang.org/issues/111922015-05-28T14:25:48Zcremno (cremno phobia)
<pre><code>$ ruby --dump=parsetree -e "$9999999999"
###########################################################
## Do NOT use this node dump for any purpose other than ##
## debug and research. Compatibility is not guaranteed. ##
###########################################################
# @ NODE_SCOPE (line: 1)
# +- nd_tbl: (empty)
# +- nd_args:
# | (null node)
# +- nd_body:
# @ NODE_NTH_REF (line: 1)
# +- nd_nth: $1410065407
</code></pre>
<p>The culprit is <a href="https://github.com/ruby/ruby/blob/4d059bf9f5f10f3d3088de49fc87e5555db7770d/parse.y#L7673" class="external">this line</a> in <code>parse.y</code> which contains a call to <code>atoi()</code>.</p>
<p>A simple, non-intrusive fix could be calling a function with well-defined behavior when the resulting value can't be represented instead (such as <code>strtoul()</code>) and of course also adding a range check. But perhaps a syntax error is undesired here.</p> Ruby master - Bug #10053 (Closed): OpenSSL: incorrect return value check of EGD functionshttps://redmine.ruby-lang.org/issues/100532014-07-17T09:01:23Zcremno (cremno phobia)
<p><a href="https://www.openssl.org/docs/crypto/RAND_egd.html#RETURN_VALUE" class="external">https://www.openssl.org/docs/crypto/RAND_egd.html#RETURN_VALUE</a></p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
index 270a4b7..a9188bc 100644
</span><span class="gd">--- a/ext/openssl/ossl_rand.c
</span><span class="gi">+++ b/ext/openssl/ossl_rand.c
</span><span class="p">@@ -135,7 +135,7 @@</span> ossl_rand_egd(VALUE self, VALUE filename)
{
SafeStringValue(filename);
<span class="gd">- if(!RAND_egd(RSTRING_PTR(filename))) {
</span><span class="gi">+ if (RAND_egd(RSTRING_PTR(filename)) == -1) {
</span> ossl_raise(eRandomError, NULL);
}
return Qtrue;
<span class="p">@@ -153,7 +153,7 @@</span> ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
SafeStringValue(filename);
<span class="gd">- if (!RAND_egd_bytes(RSTRING_PTR(filename), n)) {
</span><span class="gi">+ if (RAND_egd_bytes(RSTRING_PTR(filename), n) == -1) {
</span> ossl_raise(eRandomError, NULL);
}
return Qtrue;
</code></pre>
<p>Maybe an error message (e.g. <code>"EGD connection failed or not enough data returned to fully seed the PRNG"</code>) should also be added.</p> Ruby master - Feature #9799 (Closed): change behavior of Math::atan2 if y and x are both Float::I...https://redmine.ruby-lang.org/issues/97992014-05-03T03:16:11Zcremno (cremno phobia)
<p>The current behavior when y and x are either negative or positive infinity is:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Math</span><span class="p">.</span><span class="nf">atan2</span><span class="p">(</span><span class="no">Float</span><span class="o">::</span><span class="no">INFINITY</span><span class="p">,</span> <span class="no">Float</span><span class="o">::</span><span class="no">INFINITY</span><span class="p">)</span> <span class="c1"># raises Math::DomainError</span>
</code></pre>
<p>The attached diff changes it to:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Math</span><span class="p">.</span><span class="nf">atan2</span><span class="p">(</span><span class="no">Float</span><span class="o">::</span><span class="no">INFINITY</span><span class="p">,</span> <span class="no">Float</span><span class="o">::</span><span class="no">INFINITY</span><span class="p">)</span> <span class="c1"># => 0.7853981633974483</span>
</code></pre>
<p>I think a domain error isn't desirable here. Is it even one? Other languages like Go, Python, Java or Javascript seem to return the expected result. .NET languages return NaN.</p>
<p>ISO C99/C11 also does, if the implementation follows the normative Annex F. This isn't always the case, but there is already a special case when y and x are zero, so I think this one is acceptable, too.</p>
<p><a href="http://golang.org/src/pkg/math/atan2.go" class="external">http://golang.org/src/pkg/math/atan2.go</a><br>
<a href="http://hg.python.org/cpython/file/62438d1b11c7/Modules/mathmodule.c#l516" class="external">http://hg.python.org/cpython/file/62438d1b11c7/Modules/mathmodule.c#l516</a><br>
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#atan2%28double,%20double%29" class="external">http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#atan2%28double,%20double%29</a><br>
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.5" class="external">http://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.5</a><br>
<a href="http://port70.net/~nsz/c/c99/n1256.html#F.9.1.4" class="external">http://port70.net/~nsz/c/c99/n1256.html#F.9.1.4</a><br>
<a href="http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx" class="external">http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx</a></p> Ruby master - Bug #9797 (Closed): Math::log - missing domain error checkhttps://redmine.ruby-lang.org/issues/97972014-05-03T02:40:30Zcremno (cremno phobia)
<p><code>Math::log</code> with a negative <code>base</code> should raise a <code>Math::DomainError</code>.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Math</span><span class="p">.</span><span class="nf">log</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">)</span> <span class="c1"># raises Math::DomainError</span>
<span class="no">Math</span><span class="p">.</span><span class="nf">log</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span> <span class="c1"># doesn't (but calls `log(-1.0)` internally!)</span>
</code></pre>