https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-09-12T00:23:09ZRuby Issue Tracking SystemRuby master - Bug #6990: test_s_random_bytes_without_openssl error on Windows x64https://redmine.ruby-lang.org/issues/6990?journal_id=292462012-09-12T00:23:09Zluislavena (Luis Lavena)luislavena@gmail.com
<ul></ul><p>=begin<br>
I can confirm that after reaching 1.9GB of RAM usage, it fails with:</p>
<p>"7e7e6cb0"<br>
C:/Users/Worker/Code/ruby-2.0.0-r36949-x64-mingw32/lib/ruby/2.0.0/securerandom.rb:116:in <code>random_bytes': unknown error - CryptGenRandom failed: The parameter is incorrect. (SystemCallError) from a.rb:7:in </code>block in '<br>
from a.rb:11:in <code>loop' from a.rb:11:in </code>'</p>
<p>I'm applying the patch now and doing a build to confirm.</p>
<p>=end</p> Ruby master - Bug #6990: test_s_random_bytes_without_openssl error on Windows x64https://redmine.ruby-lang.org/issues/6990?journal_id=292472012-09-12T01:05:39Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Category</strong> set to <i>test</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>usa (Usaku NAKAMURA)</i></li><li><strong>Target version</strong> set to <i>2.0.0</i></li></ul><p>I can confirm patch work.</p>
<p>Usa, do you have any objection with path?</p>
<p>Thank you.</p> Ruby master - Bug #6990: test_s_random_bytes_without_openssl error on Windows x64https://redmine.ruby-lang.org/issues/6990?journal_id=292522012-09-12T12:36:48Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul></ul><p>Most it's okay.<br>
There is a problem in the last chunk.<br>
Rather than filesystem encoding, I think that locale encoding is suitable.</p> Ruby master - Bug #6990: test_s_random_bytes_without_openssl error on Windows x64https://redmine.ruby-lang.org/issues/6990?journal_id=292532012-09-12T12:40:00Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul></ul><p>If you can agree with my opinion, Luis, please correct the patch<br>
and commit it.<br>
Or if you cannot agree by any means, please commit it as it is :)</p> Ruby master - Bug #6990: test_s_random_bytes_without_openssl error on Windows x64https://redmine.ruby-lang.org/issues/6990?journal_id=292622012-09-13T01:10:02Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Assignee</strong> changed from <i>usa (Usaku NAKAMURA)</i> to <i>h.shirosaki (Hiroshi Shirosaki)</i></li></ul><p>Thank you Usa,</p>
<p>Hiroshi, leaving to you to commit.</p> Ruby master - Bug #6990: test_s_random_bytes_without_openssl error on Windows x64https://redmine.ruby-lang.org/issues/6990?journal_id=292782012-09-13T21:59:54Zh.shirosaki (Hiroshi Shirosaki)h.shirosaki@gmail.com
<ul></ul><p>=begin<br>
Language of FormatMessage seems not affected by console code page.</p>
<p>Test using locale:<br>
msg[0, len].force_encoding("locale").tr("\r", '').chomp</p>
<p>"locale" means console code page on Windows ruby.<br>
But changing console code page doesn't affect message language. Message seems always cp932 Japanese on Windows 7.</p>
<blockquote>
<p>type message.rb<br>
require "openssl"<br>
OpenSSL.send(:remove_const, :Random)<br>
require "securerandom"</p>
</blockquote>
<p>SecureRandom.random_bytes<br>
SecureRandom.send(:instance_variable_set, :@hProv, 0)<br>
SecureRandom.random_bytes</p>
<blockquote>
<p>chcp 932<br>
ruby message.rb<br>
V:/ruby19_mingw/lib/ruby/2.0.0/securerandom.rb:117:in <code>random_bytes': unknown error - CryptGenRandom failed: パラメーターが間違っています (SystemCallError) from message.rb:7:in </code>'</p>
</blockquote>
<blockquote>
<p>chcp 65001<br>
ruby message.rb<br>
V:/ruby19_mingw/lib/ruby/2.0.0/securerandom.rb:264:in <code>tr': invalid byte sequence in UTF-8 (Argument Error) from V:/ruby19_mingw/lib/ruby/2.0.0/securerandom.rb:264:in </code>lastWin32ErrorMessage'<br>
from V:/ruby19_mingw/lib/ruby/2.0.0/securerandom.rb:117:in <code>random_bytes' from message.rb:7:in </code>'</p>
</blockquote>
<blockquote>
<p>chcp 1252<br>
ruby message.rb<br>
V:/ruby19_mingw/lib/ruby/2.0.0/securerandom.rb:117:in <code>random_bytes': unknown error - CryptGenRandom failed: ?????????????? (SystemCallError) from message.rb:7:in </code>'</p>
</blockquote>
<p>But on Windows XP, message language seems determined by console code page. With not 932 code page, message is English.</p>
<p>To avoid <code>invalid byte sequence</code> error with String#tr, I would like to set filesystem encoding.<br>
If you know better way, please correct it.</p>
<p>=end</p> Ruby master - Bug #6990: test_s_random_bytes_without_openssl error on Windows x64https://redmine.ruby-lang.org/issues/6990?journal_id=292792012-09-13T22:01:25ZAnonymous
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r36961.<br>
Hiroshi, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>lib/securerandom.rb: fix errors on Windows</p>
<ul>
<li>
<p>lib/securerandom.rb (SecureRandom.random_bytes):<br>
Use 64bit value as pointer for Windows x64 to fix SystemCallError.</p>
</li>
<li>
<p>lib/securerandom.rb (SecureRandom.lastWin32ErrorMessage):<br>
Set proper encoding to avoid invalid byte sequence error.<br>
<a href="/issues/6990">[ruby-core:47451]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: test_s_random_bytes_without_openssl error on Windows x64 (Closed)" href="https://redmine.ruby-lang.org/issues/6990">#6990</a>]</p>
</li>
</ul>