Ruby Issue Tracking System: Issues
https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2016-04-12T15:50:52Z
Ruby Issue Tracking System
Redmine
Ruby master - Bug #12274 (Closed): accessing to instance variable should be fast.
https://redmine.ruby-lang.org/issues/12274
2016-04-12T15:50:52Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>Currently, accessing to instance variable is quite slower than accessing to local variable.<br>
I think accessing to instance variable is basic operation and it should be fast, so tried to improve.</p>
<p>patch: <a href="https://github.com/tarui/ruby/commit/dd993da80c7ad84340689137bf8b308793595cae" class="external">https://github.com/tarui/ruby/commit/dd993da80c7ad84340689137bf8b308793595cae</a></p>
<p>On mame's optcarrot benchmark, (<a href="https://github.com/mame/optcarrot/" class="external">https://github.com/mame/optcarrot/</a>)<br>
it is 10%(!) faster than trunk.<br>
It increases in the maintenance cost a little, but can I commit it?</p>
<pre><code>$ ./ruby -v --disable-gems ../../optcarrot/bin/optcarrot --benchmark ../../optcarrot/examples/Lan_Master.nes
ruby 2.4.0dev (2016-04-12 trunk 54553) [x86_64-linux]
fps: 13.664029283085743
checksum: 59662
$ ./ruby -v --disable-gems ../../optcarrot/bin/optcarrot --benchmark ../../optcarrot/examples/Lan_Master.nes
ruby 2.4.0dev (2016-04-12 fast-ivar-access 54553) [x86_64-linux]
fps: 15.120651593726231
checksum: 59662
</code></pre>
Ruby master - Feature #10548 (Open): remove callcc (Callcc is now going obsoleted. Please use Fi...
https://redmine.ruby-lang.org/issues/10548
2014-11-26T11:28:56Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>We are paying a lot of costs for callcc's consistency.<br>
and currently, we can use Fiber in many situation.</p>
<p>In <a href="https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20140517Japan" class="external">https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20140517Japan</a>,<br>
matz agreed to remove callcc.</p>
<p>If there is no refutation, remove callcc in the future version.</p>
Ruby master - Bug #9646 (Closed): Infinite loop at Hash#each
https://redmine.ruby-lang.org/issues/9646
2014-03-17T04:59:36Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>Hashでキーを同じにすると、無限ループしてしまいます。</p>
<p>再現コードは<br>
ruby -e 'h={};h[a=[]]=1;a<<1;h[[]] = 2;a.clear;h.each{|i| p i}'<br>
です。</p>
<p><code>st_foreach_check</code>で<code>callcc</code>対応のために<br>
<code>find_packed_index</code>を毎回呼んでおり、そこで<code>i</code>が進まなくなっています。<br>
そもそも、同じキーの状態を作り出せるのがどうなんだという話はあるかもしれませんが、<br>
そちらを直すのは大きな変更になりそうなので、とりあえず以下のような感じでどうでしょうか?<br>
callccでの後戻りをあきらめています。</p>
<p>#または、callccでイテレータの中に戻るのを禁止した方がよいのかもしれません。</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gd">--- a/st.c
</span><span class="gi">+++ b/st.c
</span><span class="p">@@ -394,9 +394,8 @@</span> find_entry(st_table *table, st_data_t key, st_index_t hash_val, st_index_t bin_p
}
<span class="err">
</span> static inline st_index_t
<span class="gd">-find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
</span><span class="gi">+find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key,st_index_t i)
</span> {
<span class="gd">- st_index_t i = 0;
</span> while (i < table->real_entries &&
(PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) {
i++;
<span class="p">@@ -404,6 +403,12 @@</span> find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
return i;
}
<span class="err">
</span><span class="gi">+static inline st_index_t
+find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
+{
+ return find_packed_index_from(table,hash_val,key,0);
+}
+
</span> #define collision_check 0
<span class="err">
</span> int
<span class="p">@@ -963,8 +968,8 @@</span> st_foreach_check(st_table *table, int (*func)(ANYARGS), st_data_t arg, st_data_t
if (PHASH(table, i) == 0 && PKEY(table, i) == never) {
break;
}
<span class="gd">- i = find_packed_index(table, hash, key);
- if (i == table->real_entries) {
</span><span class="gi">+ i = find_packed_index_from(table, hash, key, i);
+ if (i >= table->real_entries) {
</span> goto deleted;
}
/* fall through */
</code></pre>
Ruby master - Feature #9590 (Open): introduce st_foreach_update and st_foreach_update_check for p...
https://redmine.ruby-lang.org/issues/9590
2014-03-04T12:15:55Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>Hello,</p>
<p>I think I'll introduce st_foreach_update and st_foreach_update_check for performance.</p>
<p>For example, it is effective at Hash's rehash,dup and clone. (included in patch)</p>
<p>Are there any problem?</p>
<p>Patch is at <a href="https://gist.github.com/tarui/9345180" class="external">https://gist.github.com/tarui/9345180</a> and attached here.<br>
Some benchmarks are shown below.</p>
<pre>
$cat test.rb
require 'benchmark'
N=10**6
a={}
Benchmark.bm(8) do |x|
x.report("create") { N.times{|i| a[i] = i} }
x.report("rehash") { a.rehash }
x.report("dup") { a.dup }
x.report("clone") { a.clone }
end
$ original_ruby test.rb
user system total real
create 0.730000 0.050000 0.780000 ( 0.788674)
rehash 1.030000 0.080000 1.110000 ( 1.113006)
dup 1.120000 0.050000 1.170000 ( 1.175618)
clone 1.300000 0.010000 1.310000 ( 1.312528)
$ proposed_ruby test.rb
user system total real
create 0.710000 0.050000 0.760000 ( 0.758993)
rehash 0.020000 0.000000 0.020000 ( 0.018409)
dup 0.130000 0.050000 0.180000 ( 0.182608)
clone 0.500000 0.000000 0.500000 ( 0.509430)
$ make gcbench-rdoc | tail -n8|head -n2
original_ruby:
user system total real
159.630000 2.870000 162.500000 (163.414495)
proposed_ruby:
user system total real
152.920000 2.730000 155.650000 (156.040741)
</pre>
Ruby master - Bug #9176 (Closed): test_gc_reason failed.
https://redmine.ruby-lang.org/issues/9176
2013-11-29T21:14:14Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
test_gc_reason failed always at 'make test-all' In my environment.</p>
<ol>
<li>Failure:<br>
TestGc#test_gc_reason [.../test/ruby/test_gc.rb:84]:<br>
<{:gc_by=>:newobj}> expected but was<br>
<{:major_by=>:nofree, :gc_by=>:method, :immediate_sweep=>true}>.</li>
</ol>
<p>The number of times is too small?<br>
=end</p>
Ruby master - Bug #9105 (Closed): callcc による不整合(例:Hash)
https://redmine.ruby-lang.org/issues/9105
2013-11-13T10:50:11Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
以下のコードを実行すると、<br>
equire 'continuation'<br>
h = {1=>2,3=>4}<br>
c = nil<br>
f = false<br>
h.each { callcc {|c2| c = c2 } }<br>
unless f<br>
f = true<br>
c.call<br>
end<br>
h.each {|i| h.delete(1); p i}</p>
<p>以下のような結果になります。</p>
<p>[1, 2]<br>
[false, false]<br>
test.rb:10:in <code>each': hash modified during iteration (RuntimeError) from test.rb:10:in </code>'</p>
<p>[false, false]自体はst_foreach_checkで全く機能していない<br>
/* call func with error notice */<br>
retval = (*func)(0, 0, arg, 1);<br>
を消せばいいのですが、<br>
RuntimeErrorが発生するのはcallccによりhash_foreach_ensureの実行が2重に行われて、<br>
RHASH_ITER_LEV(hash)の管理が破綻してしまっている為です。</p>
<p>他の所でも容易に起こりうると思うのですが、未調査です。<br>
&そもそもどう対処すべきでしょう?</p>
<p>=end</p>
Ruby master - Bug #7597 (Closed): $0を変更するとbug_reportでsegvする
https://redmine.ruby-lang.org/issues/7597
2012-12-21T20:14:39Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>rb_vm_bugreport(void)の中で backtrace_symbols(trace, n)が ruby本体の代わりに$0で変更した名前を引っ張って来ています。<br>
それがrb_dump_backtrace_with_lines(n, trace, syms);の中でelf形式の実行ファイルだと思い込んで処理をしてしまっており、<br>
正しく処理されずに誤ったヘッダー情報を元にポインタ操作を行いsegv等します。</p>
<p>minitest中にsegvしたりrb_bugしたりすると、思いっきりこれをふむ事になります。<br>
例えば[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: parallel test-all で test_settracefunc が cfp consistency error (Closed)" href="https://redmine.ruby-lang.org/issues/7590">#7590</a>]。</p>
<p>抜本的な対策はまだよくわからないのですが、一時的に、<br>
rb_dump_backtrace_with_linesを使わないようにしておくべきかなと思います。</p>
<p>$ cat t.rb<br>
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" #dummy header:-)<br>
$0=<strong>FILE</strong><br>
require 'dl'<br>
p DL::CPtr.new(4)[0]</p>
<p>$ ruby t.rb<br>
DL is deprecated, please use Fiddle<br>
t.rb:4: [BUG] Segmentation fault<br>
ruby 2.0.0dev (2012-12-21 trunk 38514) [x86_64-linux]</p>
<p>-- Control frame information -----------------------------------------------<br>
c:0003 p:---- s:0009 e:000008 CFUNC :[]<br>
c:0002 p:0033 s:0005 e:001578 EVAL t.rb:4 [FINISH]<br>
c:0001 p:0000 s:0002 e:000c08 TOP [FINISH]</p>
<p>t.rb:4:in <code><main>' t.rb:4:in </code>[]'</p>
<p>-- C level backtrace information -------------------------------------------<br>
Segmentation fault (core dumped)<br>
$</p>
Ruby master - Bug #7590 (Closed): parallel test-all で test_settracefunc が cfp consistency error
https://redmine.ruby-lang.org/issues/7590
2012-12-19T18:07:25Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: parallel test-all で test_settracefunc が SEGV (Closed)" href="https://redmine.ruby-lang.org/issues/7589">#7589</a>]はr38464でなおったんですが今度は別のエラーが出るようになりました。<br>
$ while (make TESTS='-qv -j1 ruby/test_settracefunc.rb' test-all >&t.log); do echo 1; done<br>
で<br>
[BUG] vm_call_cfunc - cfp consistency error<br>
ruby 2.0.0dev (2012-12-19 trunk 38464) [x86_64-linux]</p>
<p>-- Control frame information -----------------------------------------------<br>
c:0009 p:---- s:0050 e:000049 CFUNC :map<br>
c:0008 p:0092 s:0047 e:000046 METHOD /home/tarui/svn/ruby/lib/minitest/unit.rb:912<br>
c:0007 p:0109 s:0039 e:0009c8 METHOD /home/tarui/svn/ruby/lib/test/unit/parallel.rb:48<br>
c:0006 p:0011 s:0024 e:000023 BLOCK /home/tarui/svn/ruby/lib/test/unit/parallel.rb:23 [FINISH]<br>
c:0005 p:---- s:0021 e:000020 CFUNC :map<br>
c:0004 p:0008 s:0018 e:000017 METHOD /home/tarui/svn/ruby/lib/test/unit/parallel.rb:22<br>
c:0003 p:0276 s:0013 e:000012 METHOD /home/tarui/svn/ruby/lib/test/unit/parallel.rb:120<br>
c:0002 p:0095 s:0004 e:001ff8 EVAL /home/tarui/svn/ruby/lib/test/unit/parallel.rb:181 [FINISH]<br>
c:0001 p:0000 s:0002 e:0017d8 TOP [FINISH]</p>
<p>/home/tarui/svn/ruby/lib/test/unit/parallel.rb:181:in <code><main>' /home/tarui/svn/ruby/lib/test/unit/parallel.rb:120:in </code>run'<br>
/home/tarui/svn/ruby/lib/test/unit/parallel.rb:22:in <code>_run_suites' /home/tarui/svn/ruby/lib/test/unit/parallel.rb:22:in </code>map'<br>
/home/tarui/svn/ruby/lib/test/unit/parallel.rb:23:in <code>block in _run_suites' /home/tarui/svn/ruby/lib/test/unit/parallel.rb:48:in </code>_run_suite'<br>
/home/tarui/svn/ruby/lib/minitest/unit.rb:912:in <code>_run_suite' /home/tarui/svn/ruby/lib/minitest/unit.rb:912:in </code>map'</p>
<p>-- C level backtrace information -------------------------------------------<br>
/home/tarui/svn/ruby/lib/minitest/unit.rb:912: [BUG] Segmentation fault<br>
ruby 2.0.0dev (2012-12-19 trunk 38464) [x86_64-linux]</p>
<p>-- Control frame information -----------------------------------------------<br>
c:0009 p:---- s:0050 e:000049 CFUNC :map<br>
c:0008 p:0092 s:0047 e:000046 METHOD /home/tarui/svn/ruby/lib/minitest/unit.rb:912<br>
c:0007 p:0109 s:0039 e:0009c8 METHOD /home/tarui/svn/ruby/lib/test/unit/parallel.rb:48<br>
c:0006 p:0011 s:0024 e:000023 BLOCK /home/tarui/svn/ruby/lib/test/unit/parallel.rb:23 [FINISH]<br>
c:0005 p:---- s:0021 e:000020 CFUNC :map<br>
c:0004 p:0008 s:0018 e:000017 METHOD /home/tarui/svn/ruby/lib/test/unit/parallel.rb:22<br>
c:0003 p:0276 s:0013 e:000012 METHOD /home/tarui/svn/ruby/lib/test/unit/parallel.rb:120<br>
c:0002 p:0095 s:0004 e:001ff8 EVAL /home/tarui/svn/ruby/lib/test/unit/parallel.rb:181 [FINISH]<br>
c:0001 p:0000 s:0002 e:0017d8 TOP [FINISH]</p>
<p>/home/tarui/svn/ruby/lib/test/unit/parallel.rb:181:in <code><main>' /home/tarui/svn/ruby/lib/test/unit/parallel.rb:120:in </code>run'<br>
/home/tarui/svn/ruby/lib/test/unit/parallel.rb:22:in <code>_run_suites' /home/tarui/svn/ruby/lib/test/unit/parallel.rb:22:in </code>map'<br>
/home/tarui/svn/ruby/lib/test/unit/parallel.rb:23:in <code>block in _run_suites' /home/tarui/svn/ruby/lib/test/unit/parallel.rb:48:in </code>_run_suite'<br>
/home/tarui/svn/ruby/lib/minitest/unit.rb:912:in <code>_run_suite' /home/tarui/svn/ruby/lib/minitest/unit.rb:912:in </code>map'</p>
<p>-- C level backtrace information -------------------------------------------</p>
<p>Some worker was crashed. It seems ruby interpreter's bug<br>
or, a bug of test/unit/parallel.rb. try again without -j<br>
option.</p>
Ruby master - Bug #7563 (Closed): test of gem_ext_cmake_builder in another directory
https://redmine.ruby-lang.org/issues/7563
2012-12-15T01:13:22Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>would you commit it? or can I ?</p>
<a name="Index-testrubygemstest_gem_ext_cmake_builderrb"></a>
<h1 >Index: test/rubygems/test_gem_ext_cmake_builder.rb<a href="#Index-testrubygemstest_gem_ext_cmake_builderrb" class="wiki-anchor">¶</a></h1>
<p>--- test/rubygems/test_gem_ext_cmake_builder.rb (revision 38369)<br>
+++ test/rubygems/test_gem_ext_cmake_builder.rb (working copy)<br>
@@ -36,7 +36,7 @@<br>
assert_equal "cmake . -DCMAKE_INSTALL_PREFIX=#{@dest_path}", output.shift<br>
assert_match(/#{@ext}/, output.shift)<br>
assert_equal make_command, output.shift</p>
<ul>
<li>assert_equal "", output.shift</li>
</ul>
<ul>
<li>assert_equal "", output.shift.gsub(/^make[1]: (?:Entering|Leaving) directory .*\n/,"")<br>
assert_equal make_command + " install", output.shift<br>
assert_match(/test.txt/, output.shift)<br>
end</li>
</ul>
Ruby master - Bug #7562 (Closed): __FILE__ encoding in Windows
https://redmine.ruby-lang.org/issues/7562
2012-12-15T00:40:29Z
tarui (Masaya Tarui)
tarui@prx.jp
<h2>[ruby-list:49085] ですが、bugっぽいので勝手にバグ登録させていただきます。<br>
trunkでも同じでした。</h2>
<p>Ruby2.0.0 の挙動について疑問があるので質問させて頂きます。</p>
<p>WindowsXP上のコンソールからパスに日本語を含むスクリプトを起動した場合に、<br>
<strong>FILE</strong> のエンコーディング(String#encoding がではなくデータ的な意味で)<br>
が UTF-8 になるのは仕様変更なのでしょうか。(コンソールから指定した部分だけが化ける)</p>
<p>(実行バイナリは arton さんの <a href="http://www.artonx.org/data/asr/Ruby-2.0.0.msi" class="external">http://www.artonx.org/data/asr/Ruby-2.0.0.msi</a> を使用)</p>
<a name="テストスクリプトD日本語あいうえおrb"></a>
<h1 >テストスクリプト(D:\日本語\あいうえお.rb)<a href="#テストスクリプトD日本語あいうえおrb" class="wiki-anchor">¶</a></h1>
<p>f0 = File.expand_path($0)<br>
puts "$0:#{f0},#{f0.encoding}"<br>
file = File.expand_path(<strong>FILE</strong>)<br>
puts "<strong>FILE</strong>:#{file},#{file.encoding}"</p>
<p>■パターン1(ファイルだけ指定)<br>
D:\日本語>ruby -v あいうえお.rb<br>
ruby 2.0.0dev (2012-11-01) [i386-mswin32_100]<br>
$0:D:/日本語/あいうえお.rb,Windows-31J<br>
<strong>FILE</strong>:D:/日本語/縺ゅ>縺・∴縺・rb,Windows-31J</p>
<p>■パターン2(フルパスで指定)<br>
D:\日本語>ruby -v D:\日本語\あいうえお.rb<br>
ruby 2.0.0dev (2012-11-01) [i386-mswin32_100]<br>
$0:D:/日本語/あいうえお.rb,Windows-31J<br>
<strong>FILE</strong>:D:/譌・譛ャ隱・縺ゅ>縺・∴縺・rb,Windows-31J</p>
<p>■参考(Ruby1.9.3)<br>
jobs:0 $ ruby -v あいうえお.rb<br>
ruby 1.9.3dev (2011-05-08) [i386-mingw32]<br>
$0:D:/日本語/あいうえお.rb,Windows-31J<br>
<strong>FILE</strong>:D:/日本語/あいうえお.rb,Windows-31J</p>
<p>よろしくお願いいたします。</p>
Ruby master - Bug #7520 (Closed): irb/completion でインスタンス変数がチェックされていない
https://redmine.ruby-lang.org/issues/7520
2012-12-06T01:12:50Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>BugなのかFeatureなのか微妙な所なのですが、<br>
現在はcompletionでインスタンス変数が対象になっていません。</p>
<p>インスタンス変数も対象にするパッチです。<br>
<a href="https://gist.github.com/4216894" class="external">https://gist.github.com/4216894</a></p>
Backport193 - Backport #7468 (Closed): GC_GUARD漏れもしくはmark漏れっぽいエラーが発生してます。
https://redmine.ruby-lang.org/issues/7468
2012-11-30T03:31:21Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>いつからかtest-allで時々エラーが発生するようになってます。</p>
<p>make test-all TESTS="-qv -n /test_string$$/"</p>
<p>でsegvや</p>
<ol>
<li>Error:<br>
test_string(DL::TestFunc):<br>
ArgumentError: assertion message must be String or Proc, but Thread::Backtrace was given.<br>
などと言われるようになりました。<br>
GC.stress = true なのと、Thread::Backtraceが通常のpassでは入る事はないっぽいのでGC周りのバグだと思います。</li>
</ol>
Ruby master - Bug #7455 (Closed): Queue#popで待っている間にtrapに入りその時にQueue#pushされると、Queue#popから戻ってこなくなる。
https://redmine.ruby-lang.org/issues/7455
2012-11-28T22:36:39Z
tarui (Masaya Tarui)
tarui@prx.jp
<h2>以下スクリプトを実行すると期待したように終わらずに、deadlockしてしまいます。<br>
ささださんよろしく。</h2>
<p>require 'thread'</p>
<p>que = Queue.new<br>
th = Thread.new{<br>
sleep 0.1<br>
Process.kill(:INT,$$)<br>
sleep 0.1<br>
que.push 2<br>
}<br>
Signal.trap :INT do<br>
p :trap_task<br>
123456**100000 / 456 ** 10000<br>
p :trap_task_end<br>
end<br>
puts "que.pop"<br>
p que.pop<br>
puts "success!"</p>
Ruby master - Bug #4591 (Closed): (1.5...2).max #=> 1 (Range#max)
https://redmine.ruby-lang.org/issues/4591
2011-04-21T00:42:24Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>現在、(1.5...2).maxが1になります。<br>
beginより小さい値が返ってくるのは違和感があります。</p>
<p>終端を含まないRangeについて、endがIntegerである時にend-1を返していますが、<br>
それはbeginもIntegerである事が想定されてると思います。<br>
結局 beginがIntegerじゃないときは、endがIntegerでない時と同様に<br>
maxが定義できなさそうなので、やはり同様にErrorにした方が親切かと思います。</p>
<p>以下のパッチを入れていいですか?</p>
<a name="Index-rangec"></a>
<h1 >Index: range.c<a href="#Index-rangec" class="wiki-anchor">¶</a></h1>
<p>--- range.c (リビジョン 31313)<br>
+++ range.c (作業コピー)<br>
@@ -670,6 +670,9 @@<br>
rb_raise(rb_eTypeError, "cannot exclude non Integer end value");</p>
<pre><code> }
if (c == 0) return Qnil;
</code></pre>
<ul>
<li>
<pre><code> if (!FIXNUM_P(b) && !rb_obj_is_kind_of(b,rb_cInteger)) {
</code></pre>
</li>
<li>
<pre><code> rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
</code></pre>
</li>
<li>
<pre><code> }
if (FIXNUM_P(e)) {
return LONG2NUM(FIX2LONG(e) - 1);
}
</code></pre>
</li>
</ul>
<a name="Index-testrubytest_rangerb"></a>
<h1 >Index: test/ruby/test_range.rb<a href="#Index-testrubytest_rangerb" class="wiki-anchor">¶</a></h1>
<p>--- test/ruby/test_range.rb (リビジョン 31313)<br>
+++ test/ruby/test_range.rb (作業コピー)<br>
@@ -68,6 +68,8 @@<br>
assert_equal(2.0, (1.0..2.0).max)<br>
assert_equal(nil, (2.0..1.0).max)<br>
assert_raise(TypeError) { (1.0...2.0).max }</p>
<ul>
<li>
<p>assert_raise(TypeError) { (1...1.5).max }</p>
</li>
<li>
<p>assert_raise(TypeError) { (1.5...2).max }</p>
<p>assert_equal(-0x80000002, ((-0x80000002)...(-0x80000001)).max)</p>
</li>
</ul>
Ruby master - Bug #4177 (Closed): wrong fixed value at test/rexml/test_sax.rb(test_socket)
https://redmine.ruby-lang.org/issues/4177
2010-12-21T01:10:45Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
test/rexml/test_sax.rb の test_socketでportが12345番固定でテストされているため、<br>
12345番が使用されている時にerrorになります。<br>
テスト内容を見るに固定する必要はなさそうなので普通にシステムに割り振ってもらえばいいと思います。</p>
<p>#とあるアンチウィルスソフトがこのポートを占拠していたりします。<br>
=end</p>
Ruby master - Bug #4176 (Closed): wrong fixed value at test_contrib.rb(test_pos)
https://redmine.ruby-lang.org/issues/4176
2010-12-21T01:02:14Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
test/rexml/test_contrib.rbのtest_posでtestfileが/tmpの存在を仮定してますが、<br>
Tempfileを使うべきだと思います。</p>
<p>#windowsでは標準では/tmpがないのでerrorになります。<br>
=end</p>
Ruby master - Bug #4131 (Closed): can't set length of shared string error in IO#read
https://redmine.ruby-lang.org/issues/4131
2010-12-07T22:28:55Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
IO#readにおいて、<br>
lengthがnilでbufferにsharedなStringを指定したときに以下のようにエラーになります。</p>
<blockquote>
<p>ruby -ve "a='abcdefghijkl';b=a[1,3];STDIN.read(nil,a)"<br>
ruby 1.9.3dev (2010-12-07 trunk 30119) [i386-mswin32_90]<br>
-e:1:in <code>read': can't set length of shared string (RuntimeError) from -e:1:in </code>'</p>
</blockquote>
<h1>patchを貼り付けますが、この後、他のbugfixのためにリファクタリング予定です。<br>
Index: io.c</h1>
<p>--- io.c (リビジョン 30119)<br>
+++ io.c (作業コピー)<br>
@@ -2212,7 +2212,10 @@<br>
rb_scan_args(argc, argv, "02", &length, &str);</p>
<pre><code> if (NIL_P(length)) {
</code></pre>
<ul>
<li>
<pre><code> if (!NIL_P(str)) StringValue(str);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> if (!NIL_P(str)){
</code></pre>
</li>
<li>
<pre><code> StringValue(str);
</code></pre>
</li>
<li>
<pre><code> rb_str_modify(str);
</code></pre>
</li>
<li>
<pre><code> }
GetOpenFile(io, fptr);
rb_io_check_char_readable(fptr);
return read_all(fptr, remain_size(fptr), str);
</code></pre>
</li>
</ul>
<p>=end</p>
Ruby master - Bug #3452 (Closed): ENV 'make' is not considered in the rubygems test.
https://redmine.ruby-lang.org/issues/3452
2010-06-19T12:33:58Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
Hi, Eric</p>
<p>the test fails follows.</p>
<p>$make=<code>which make</code> ruby test/rubygems/test_gem_ext_configure_builder.rb</p>
<ol>
<li>Failure:<br>
test_self_build(TestGemExtConfigureBuilder) [test/rubygems/test_gem_ext_configure_builder.rb:33]:<br>
Expected "make", not "/usr/bin/make".</li>
<li>Failure:<br>
test_self_build_has_makefile(TestGemExtConfigureBuilder) [test/rubygems/test_gem_ext_configure_builder.rb:79]:<br>
Expected "make", not "/usr/bin/make".</li>
</ol>
<p>on Windows,</p>
<blockquote>
<p>nmake install test-all<br>
also fails.<br>
because defined MAKE by 'install' target, and environment's variable name is not case-sensitive on Windows.</p>
</blockquote>
<p>I have some questions.</p>
<ol>
<li>
<p>Is it intentional to use not ENV['MAKE'] but ENV['make'] at rubygems/ext/builder.rb ?</p>
</li>
<li>
<p>What do you want to test by test_self_build, test_self_build_has_makefile, test_class_build and test_clas_make?<br>
Is it necessary to check make command?<br>
If you think that, you should do unsetenv or check ENV.</p>
</li>
</ol>
<p>I think that the redefine of MAKE at 'make install' is wrong, but it is another problem.<br>
=end</p>
Ruby master - Bug #3433 (Closed): Error that occurs by BasicSocket#sendmsg
https://redmine.ruby-lang.org/issues/3433
2010-06-13T03:01:59Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
r24199と関連するのですが、sendmsgが実装されていない場合に発生するエラーとして、<br>
こちらの環境ではNotImplementedErrorではなくErrno::ENOSYSが発生します。</p>
<p>ドキュメントにはエラーについて書いていないのですが、どちらが正解かまた両方ありえるのか、<br>
どうなんでしょうか?</p>
<p>これで、<br>
test_udp_server(TestSocket)<br>
test_sendmsg_nonblock_error(TestSocketNonblock)<br>
がErrorになっています。<br>
=end</p>
Ruby master - Bug #3430 (Closed): ENV 'MAKE' is not considered in the gem test.
https://redmine.ruby-lang.org/issues/3430
2010-06-12T07:04:33Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
nmake install test-all<br>
とした場合に、テストで環境変数を考慮していないため、</p>
<p>test_self_build_has_makefile(TestGemExtConfigureBuilder)<br>
test_class_build(TestGemExtExtConfBuilder)<br>
test_class_build(TestGemExtExtConfBuilder)<br>
で<br>
Expected "nmake", not ""nmake" > .installed.list".<br>
などと言われて失敗します。</p>
<p>テストで環境変数を見るようにすべきでしょうか?<br>
=end</p>
Ruby master - Feature #3328 (Rejected): Kernel#p outputs as default_internal encoding, and so on
https://redmine.ruby-lang.org/issues/3328
2010-05-21T08:10:17Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
樽家です。</p>
<p>Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: String#inspect as default_internal encoding (Closed)" href="https://redmine.ruby-lang.org/issues/2102">#2102</a> <a href="/issues/2102">[ruby-dev:39343]</a> でString#inspectについては強制的にencodingを揃えるようになりましたが、SymbolやRegexpについてはそうなっておらず、同じような簡単にエラーになる状態になっています。ユーザー定義のinspectにも同様です。またにinspectで文字コードの違いが区別できません。</p>
<p>そこで、Kernel#pで表示する前やArrayやHashで各inspect結果をマージする前に、String#inspectと同様な処理を行うのはどうでしょうか?具体的にはinspectで想定するEncodingと異なる場合に、非ASCII文字をエスケープ表示にするString#inspect_encodeを追加し、それをrb_inspectから呼ぶ事を提案したいと思います。ASCII文字については手を加えないため、不可逆ですが実用上は問題ないと思います。<br>
ご検討をお願いします。</p>
<p>以下に現状と提案後の結果、Kernel#pの定義の変更を示します。<br>
またこの変更を行うpatchを添付します。</p>
<blockquote>
<p>cat inspect.rb</p>
</blockquote>
<a name="---encoding-utf-8-"></a>
<h1 >-<em>- encoding: utf-8 -</em>-<a href="#---encoding-utf-8-" class="wiki-anchor">¶</a></h1>
<p>Encoding.default_external = "WINDOWS-31J"<br>
STDOUT.set_encoding "WINDOWS-31J"<br>
a = "あ"<br>
su = a.intern<br>
se = a.encode("euc-jp").intern<br>
sw = a.encode("windows-31j").intern<br>
ru= /#{a}/<br>
re= /#{a.encode("euc-jp")}/<br>
rw= /#{a.encode("windows-31j")}/<br>
hash = { su => se }<br>
p su,se,sw,ru,re,rw<br>
p hash rescue p $!<br>
p [ru,re,rw,su,se,sw] rescue p $!</p>
<blockquote>
<p>ruby_org inspect.rb<br>
:あ<br>
:あ<br>
:あ<br>
/あ/<br>
/あ/<br>
/あ/<br>
#<Encoding::CompatibilityError: incompatible character encodings: UTF-8 and EUC-JP><br>
#<Encoding::CompatibilityError: incompatible character encodings: UTF-8 and EUC-JP></p>
</blockquote>
<blockquote>
<p>ruby_new inspect.rb<br>
:\u3042<br>
:\x{A4A2}<br>
:あ<br>
/\u3042/<br>
/\x{A4A2}/<br>
/あ/<br>
{:\u3042=>:\x{A4A2}}<br>
[/\u3042/, /\x{A4A2}/, /あ/, :\u3042, :\x{A4A2}, :あ]</p>
</blockquote>
<p>また、<br>
Encoding.default_external = "WINDOWS-31J"<br>
STDOUT.set_encoding "WINDOWS-31J"<br>
class A ;def inspect ; "あ".encode("euc-jp") end ; end<br>
p A.new<br>
puts A.new.inspect<br>
puts A.new.inspect.inspect_encode<br>
の結果が<br>
\x{A4A2}<br>
あ<br>
\x{A4A2}<br>
となり、pの定義が少し変わります。<br>
=end</p>
Ruby master - Bug #3319 (Closed): Regexp#unionの説明と動作で食い違いがある。
https://redmine.ruby-lang.org/issues/3319
2010-05-19T21:43:03Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
樽家です。</p>
<p><a href="https://blade.ruby-lang.org/ruby-dev/41247">[ruby-dev:41247]</a>から議論したもので、Regexp#unionの説明と動作で食い違いがあります。</p>
<p>食い違いの具体的な例については、<br>
<a href="https://blade.ruby-lang.org/ruby-dev/41247">[ruby-dev:41247]</a>及び<a href="https://blade.ruby-lang.org/ruby-dev/41267">[ruby-dev:41267]</a>を参照ください。<br>
内容としては、<br>
ドキュメントでは要素のどれにでもマッチする正規表現を返すとしているのに対し、<br>
実装では、<br>
・後方参照を含む場合に他の要素の影響を受けて参照対象がずれる可能性がある。<br>
・文字コード10を意味していた'\10'が後方参照として扱われる可能性がある。<br>
・同じ名前の名前付き捕獲式集合を持つ要素同士のunionではエラーになる。<br>
といったものです。</p>
<p>スレッドの中では動作の方を仕様とするという意見でしたので、苦手ながら英語ドキュメントの修正版を考えてみました。<br>
結局 string-operated と probably を追加しただけですが、こんなのでいいんでしょうか?。。。</p>
<p>Return a Regexp object that is the string-operated union of the given patterns, i.e.,<br>
will probably match any of its parts. The patterns can be Regexp objects, in<br>
which case their options will be preserved, or Strings. If no<br>
arguments are given, returns /(?!)/.<br>
=end</p>
Ruby master - Bug #3314 (Closed): ruby_dbl2cstrで不具合
https://redmine.ruby-lang.org/issues/3314
2010-05-19T00:46:11Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
樽家です。</p>
<p>r27774でruby_dbl2cstrが分離されていますが、これまでString型をリサイズして処理してた所で、<br>
固定長のbufをそのまま使おうとして不具合が起きています。</p>
<p>ruby.exe -rscanf -e 'p "0x1.deadbeefp+99".scanf("%A")'</p>
<p>windowsではこれで落ちました。<br>
元のString型を使うコードに戻したほうがよいと思います。<br>
=end</p>
Ruby master - Bug #3307 (Closed): ext/tk がheader fileの有無を誤判定する
https://redmine.ruby-lang.org/issues/3307
2010-05-18T04:41:14Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
樽家です。<br>
tcl.hが無いのにコンパイルをしようとして失敗します。<br>
mkmf.logを見ると次のようになっていました。</p>
<p>"cl -nologo -E -I../../.ext/include/i386-mswin32_90 -I../../../include -I../../../ext/tk -DPACKAGE_NAME="" -DPACKAGE_TARNAME="" -DPACKAGE_VERSION="" -DPACKAGE_STRING="" -DPACKAGE_BUGREPORT="" -DHAVE_NO_LPFN_DECLS=1 -DHAVE_NO_FINDEX_ENUMS=1 -DTCL_CFGVAL_ENCODING="cp1252" -DTCL_CFG_OPTIMIZED=1 -DTCL_CFG_DEBUG=1 -DHAVE_UXTHEME_H=1 -MD -Zi -W2 -wd4996 -O2sy- -Zm600 -I/mingw/include conftest.c -P"<br>
conftest.c</p>
<p>checked program was:<br>
/* begin <em>/<br>
1: #include "ruby.h"<br>
2:<br>
3: #define WIN32_LEAN_AND_MEAN<br>
4: #define WIN32<br>
5: #include <winsock2.h><br>
6: #include <ws2tcpip.h><br>
7: #include <windows.h><br>
8: tcl.h<br>
/</em> end */</p>
<p>"cl -nologo -E -I../../.ext/include/i386-mswin32_90 -I../../../include -I../../../ext/tk -I/mingw/include -DPACKAGE_NAME="" -DPACKAGE_TARNAME="" -DPACKAGE_VERSION="" -DPACKAGE_STRING="" -DPACKAGE_BUGREPORT="" -DHAVE_NO_LPFN_DECLS=1 -DHAVE_NO_FINDEX_ENUMS=1 -DTCL_CFGVAL_ENCODING="cp1252" -DTCL_CFG_OPTIMIZED=1 -DTCL_CFG_DEBUG=1 -DHAVE_UXTHEME_H=1 -MD -Zi -W2 -wd4996 -O2sy- -Zm600 conftest.c -P"<br>
conftest.c</p>
<p>checked program was:<br>
/* begin <em>/<br>
1: #include "ruby.h"<br>
2:<br>
3: #define WIN32_LEAN_AND_MEAN<br>
4: #define WIN32<br>
5: #include <winsock2.h><br>
6: #include <ws2tcpip.h><br>
7: #include <windows.h><br>
8: tk.h<br>
/</em> end */</p>
<p>パッチです。</p>
<a name="Index-exttkextconfrb"></a>
<h1 >Index: ext/tk/extconf.rb<a href="#Index-exttkextconfrb" class="wiki-anchor">¶</a></h1>
<p>--- ext/tk/extconf.rb (リビジョン 27864)<br>
+++ ext/tk/extconf.rb (作業コピー)<br>
@@ -989,7 +989,7 @@<br>
end</p>
<pre><code>if TclConfig_Info['TCL_INCLUDE_SPEC'] &&
</code></pre>
<ul>
<li>
<pre><code> have_tcl_h = try_cpp('tcl.h', TclConfig_Info['TCL_INCLUDE_SPEC'])
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> have_tcl_h = try_cpp('#include<tcl.h>', TclConfig_Info['TCL_INCLUDE_SPEC'
</code></pre>
</li>
</ul>
<p>])<br>
$INCFLAGS << " " << TclConfig_Info['TCL_INCLUDE_SPEC']<br>
elsif have_tcl_h = have_header('tcl.h')<br>
# find<br>
@@ -1009,7 +1009,7 @@<br>
end</p>
<pre><code>if TkConfig_Info['TK_INCLUDE_SPEC'] &&
</code></pre>
<ul>
<li>
<pre><code> have_tk_h = try_cpp('tk.h', TkConfig_Info['TK_INCLUDE_SPEC'])
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> have_tk_h = try_cpp('#include<tk.h>', TkConfig_Info['TK_INCLUDE_SPEC'])
</code></pre>
$INCFLAGS << " " << TkConfig_Info['TK_INCLUDE_SPEC']<br>
elsif have_tk_h = have_header('tk.h')
<a name="find"></a>
<h1 >find<a href="#find" class="wiki-anchor">¶</a></h1>
</li>
</ul>
<p>=end</p>
Ruby master - Bug #3305 (Closed): test_processのMANDATORY_ENVS
https://redmine.ruby-lang.org/issues/3305
2010-05-17T21:48:35Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
現状だと以下のようになります。OSはWindowsXP SP3です。</p>
<blockquote>
<p>c:\bin\ruby.exe test\ruby\test_process.rb<br>
(snip)</p>
</blockquote>
<ol start="2">
<li>Failure:<br>
test_execopts_env(TestProcess) [test/ruby/test_process.rb:252]:<br>
<"PATH\n"> expected but was<br>
<"">.<br>
(snip)</li>
<li>Failure:<br>
test_execopts_unsetenv_others(TestProcess) [test/ruby/test_process.rb:290]:<br>
<"A=B\n"> expected but was<br>
<"">.<br>
(snip)<br>
56 tests, 132 assertions, 2 failures, 0 errors, 8 skips</li>
</ol>
<p>どうやら、起動時にSystemRootが必要なようで以下で直ります。</p>
<a name="Index-testrubytest_processrb"></a>
<h1 >Index: test/ruby/test_process.rb<a href="#Index-testrubytest_processrb" class="wiki-anchor">¶</a></h1>
<p>--- test/ruby/test_process.rb (リビジョン 27851)<br>
+++ test/ruby/test_process.rb (作業コピー)<br>
@@ -222,7 +222,7 @@<br>
when /linux/<br>
MANDATORY_ENVS << 'LD_PRELOAD'<br>
when /mswin|mingw/</p>
<ul>
<li>MANDATORY_ENVS.concat(%w[HOME USER TMPDIR])</li>
</ul>
<ul>
<li>MANDATORY_ENVS.concat(%w[HOME USER TMPDIR SystemRoot])<br>
end<br>
if e = RbConfig::CONFIG['LIBPATHENV']<br>
MANDATORY_ENVS << e</li>
</ul>
<p>結果、</p>
<blockquote>
<p>c:\bin\ruby.exe test\ruby\test_process.rb<br>
(snip)<br>
56 tests, 143 assertions, 0 failures, 0 errors, 8 skips<br>
=end</p>
</blockquote>
Ruby master - Bug #3296 (Closed): windows で iconv.dll の使用する MSVC runtime DLL のバージョンが、ruby 本体が使用する...
https://redmine.ruby-lang.org/issues/3296
2010-05-15T01:24:52Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
樽家です。</p>
<p>ランタイムが一致していないiconv.dllをロードする環境で、以下のソース</p>
<p>require 'iconv'</p>
<p>Iconv.iconv("utf-8", "SJIS", "heh")<br>
Iconv.iconv("utf-8", "X-UKNOWN", "heh")</p>
<p>を実行すると、<br>
/soft/iconv.rb:4: [BUG] rb_sys_fail(iconv("utf-8", "X-UKNOWN")) - errno == 0<br>
と言われます。<br>
ランタイムが一致していない場合、errnoをうまく更新できないために、<br>
iconvで失敗した場合に、Iconv::BrokenLibrary例外 を出力するのが正しいはずです。</p>
<p>所で、根本的にはerrnoがうまく取れればいいため、以下のようなPatchを書いてみました。<br>
iconv.dllで使用している _errno() を調べてそれを参照するようにします。<br>
取り込み可能でしょうか?</p>
<a name="Index-includerubywin32h"></a>
<h1 >Index: include/ruby/win32.h<a href="#Index-includerubywin32h" class="wiki-anchor">¶</a></h1>
<h1>--- include/ruby/win32.h (リビジョン 27790)<br>
+++ include/ruby/win32.h (作業コピー)<br>
@@ -274,6 +274,9 @@<br>
extern int fcntl(int, int, ...);<br>
extern rb_pid_t rb_w32_getpid(void);<br>
extern rb_pid_t rb_w32_getppid(void);<br>
+<br>
+extern void *rb_w32_GetImportFunctionPtr(const char *,const char *);<br>
+<br>
#if !defined(<strong>BORLANDC</strong>)<br>
extern int rb_w32_isatty(int);<br>
#endif<br>
Index: win32/win32.c</h1>
<p>--- win32/win32.c (リビジョン 27790)<br>
+++ win32/win32.c (作業コピー)<br>
@@ -29,6 +29,8 @@<br>
#include <share.h><br>
#include <shlobj.h><br>
#include <mbstring.h><br>
+#include <imagehlp.h><br>
+<br>
#if _MSC_VER >= 1400<br>
#include <crtdbg.h><br>
#include <rtcapi.h><br>
@@ -5641,3 +5643,32 @@</p>
<pre><code> return *ip < 0;
</code></pre>
<p>}<br>
#endif<br>
+<br>
+void *<br>
+rb_w32_GetImportFunctionPtr(const char *modname,const char *funcname){</p>
<ul>
<li>HMODULE hmod;</li>
<li>ULONG size;</li>
<li>const IMAGE_IMPORT_DESCRIPTOR* desc;</li>
<li>hmod = GetModuleHandle(modname);</li>
<li>if(!hmod)return NULL;</li>
<li>desc = ImageDirectoryEntryToData(hmod,TRUE,IMAGE_DIRECTORY_ENTRY_IMPORT,&size);</li>
<li>if(!desc)return NULL;</li>
<li>while(desc->Name){</li>
<li>PIMAGE_THUNK_DATA piat,pint;</li>
<li>PIMAGE_IMPORT_BY_NAME pii;</li>
<li>pint = (PIMAGE_THUNK_DATA)((char *)hmod + desc->Characteristics);</li>
<li>piat = (PIMAGE_THUNK_DATA)((char *)hmod + desc->FirstThunk);</li>
<li>while(piat->u1.Function){</li>
<li>
<pre><code> pii = (PIMAGE_IMPORT_BY_NAME)((char *)hmod+ pint->u1.AddressOfData);
</code></pre>
</li>
<li>
<pre><code> if(strcmp(pii->Name,funcname)==0){
</code></pre>
</li>
<li>
<pre><code> return (void *)piat->u1.Function;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> piat++;
</code></pre>
</li>
<li>
<pre><code> pint++;
</code></pre>
</li>
<li>}</li>
<li>desc++;</li>
<li>}</li>
<li>return NULL;<br>
+}</li>
<li>
<li>
</ul>
<a name="Index-win32Makefilesub"></a>
<h1 >Index: win32/Makefile.sub<a href="#Index-win32Makefilesub" class="wiki-anchor">¶</a></h1>
<h1>--- win32/Makefile.sub (リビジョン 27790)<br>
+++ win32/Makefile.sub (作業コピー)<br>
@@ -212,7 +212,7 @@<br>
EXTLIBS =<br>
!endif<br>
!if !defined(LIBS)<br>
-LIBS = oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib $(EXTLIBS)<br>
+LIBS = oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib imagehlp.lib $(EXTLIBS)<br>
!endif<br>
!if "$(ENABLE_WIN95)" == "yes"<br>
LIBS = unicows.lib $(LIBS)<br>
Index: ext/iconv/iconv.c</h1>
<p>--- ext/iconv/iconv.c (リビジョン 27790)<br>
+++ ext/iconv/iconv.c (作業コピー)<br>
@@ -130,6 +130,14 @@</p>
<p>static VALUE charset_map;</p>
<ul>
<li>
</ul>
<p>+#ifdef _WIN32<br>
+static int* (* _iconv_errno)(void);<br>
+#undef errno<br>
+#define errno (<em>_iconv_errno())<br>
+#endif<br>
+<br>
+<br>
/</em></p>
<ul>
<li>
<p>Document-method: charset_map</p>
</li>
<li>
<p>call-seq: Iconv.charset_map<br>
@@ -1212,5 +1220,12 @@</p>
<p>rb_gc_register_address(&charset_map);<br>
charset_map = rb_hash_new();<br>
rb_define_singleton_method(rb_cIconv, "charset_map", charset_map_get, 0);</p>
</li>
</ul>
<ul>
<li>
</ul>
<p>+#ifdef _WIN32</p>
<ul>
<li>_iconv_errno = rb_w32_GetImportFunctionPtr("iconv.dll","_errno");</li>
<li>if(!_iconv_errno)</li>
<li>_iconv_errno = _errno;<br>
+#endif</li>
<li>
</ul>
<p>}<br>
=end</p>
Ruby master - Bug #3262 (Closed): can't create fiber & SEGV in windows
https://redmine.ruby-lang.org/issues/3262
2010-05-09T06:48:07Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
windowsにおいて fiber が作れなくなってSEGVする事があります。</p>
<p>[BUG] Segmentation fault<br>
ruby 1.9.2dev (2010-05-09 trunk 27684) [i386-mswin32_90]</p>
<h2>-- control frame ----------<br>
c:0001 p:---- s:0001 b:-001 l:000000 d:000000 ------</h2>
<p>再現環境は作れてませんが、こちらではnmake test-allしたときのtest_many_fibersで必ず落ちました。<br>
#単体でtest_fiber.rbを動かしても落ちない。。。</p>
<p>作成に失敗する場合のエラーを調べると「このコマンドを実行するのに十分な記憶域がありません。」と言われています。<br>
またSEGVが発生するのは生成に失敗した場合にチェックが入っておらず無効なハンドルへ切り替えようとするからです。<br>
( SwitchToFiber(0); を実行して落ちる。)</p>
<p>これらを解消するために以下のパッチを当てたところ今は動いていますが、Fiberの理論的な制限数に対して実際に生成できてる数が合ってるのかわからず、根本的な解決になってるのかわかりません。</p>
<a name="Index-contc"></a>
<h1 >Index: cont.c<a href="#Index-contc" class="wiki-anchor">¶</a></h1>
<p>--- cont.c (リビジョン 27685)<br>
+++ cont.c (作業コピー)<br>
@@ -548,6 +548,14 @@</p>
<p>#ifdef _WIN32<br>
fib->fib_handle = CreateFiberEx(size - 1, size, 0, fiber_entry, NULL);</p>
<ul>
<li>if(fib->fib_handle==NULL){</li>
<li>
<pre><code> //try release unnecessary fibers & retry create
</code></pre>
</li>
<li>
<pre><code> rb_gc();
</code></pre>
</li>
<li>
<pre><code> fib->fib_handle = CreateFiberEx(size - 1, size, 0, fiber_entry, NULL);
</code></pre>
</li>
<li>
<pre><code> if(fib->fib_handle==NULL){
</code></pre>
</li>
<li>
<pre><code> rb_raise(rb_eFiberError, "can't create fiber");
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>}<br>
#else /* not WIN32 */<br>
ucontext_t *context = &fib->context;</li>
</ul>
<p>ちなみに手元でnmake test-allで走らせた場合では1300個から1600個弱生成するたびに領域が足りないと言われてるようなのですが、<br>
これは何が影響してきまるんでしょうか?<br>
=end</p>
Ruby master - Bug #3258 (Closed): Segmentation fault in Bigdecimal.new
https://redmine.ruby-lang.org/issues/3258
2010-05-08T09:24:50Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
GC.stress = true<br>
require 'bigdecimal'<br>
1000.times{|i| puts BigDecimal.new("1" + "0"*i) }<br>
を実行すると、</p>
<p>ruby 1.9.2dev (2010-05-07 trunk 27658) [i386-mswin32_90]<br>
0.1E1<br>
0.1E2<br>
0.1E3<br>
0.1E4<br>
0.1E5<br>
0.1E6<br>
0.1E7<br>
0.1E8<br>
0.1E9<br>
0.1E10<br>
0.46454294919296E12<br>
0.4294892378E12<br>
0.42949672324294858116E16<br>
/soft/ruby/build/t2.rb:3: [BUG] Segmentation fault<br>
ruby 1.9.2dev (2010-05-07 trunk 27658) [i386-mswin32_90]</p>
<h2>-- control frame ----------<br>
c:0009 p:---- s:0022 b:0022 l:000021 d:000021 CFUNC :to_s<br>
c:0008 p:---- s:0020 b:0020 l:000019 d:000019 CFUNC :puts<br>
c:0007 p:---- s:0018 b:0018 l:000017 d:000017 CFUNC :puts<br>
c:0006 p:0033 s:0014 b:0014 l:00220c d:000013 BLOCK /soft/ruby/build/t2.rb:3<br>
c:0005 p:---- s:0011 b:0011 l:000010 d:000010 FINISH<br>
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :times<br>
c:0003 p:0040 s:0006 b:0006 l:00220c d:00134c EVAL /soft/ruby/build/t2.rb:3<br>
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH<br>
c:0001 p:0000 s:0002 b:0002 l:00220c d:00220c TOP</h2>
<p>-- Ruby level backtrace information ----------------------------------------<br>
/soft/ruby/build/t2.rb:3:in <code><main>' /soft/ruby/build/t2.rb:3:in </code>times'<br>
/soft/ruby/build/t2.rb:3:in <code>block in <main>' /soft/ruby/build/t2.rb:3:in </code>puts'<br>
/soft/ruby/build/t2.rb:3:in <code>puts' /soft/ruby/build/t2.rb:3:in </code>to_s'</p>
<p>[NOTE]<br>
You may have encountered a bug in the Ruby interpreter or extension libraries.<br>
Bug reports are welcome.<br>
For details: <a href="http://www.ruby-lang.org/bugreport.html" class="external">http://www.ruby-lang.org/bugreport.html</a></p>
<p>This application has requested the Runtime to terminate it in an unusual way.<br>
Please contact the application's support team for more information.</p>
<p>のように落ちます。(それ以前に値がおかしくなっていますが)<br>
bigdecimal.cのVpAllocにおいて、bufがvolatile宣言されていますが、対応する領域が最適化によって最後に使用された後に違う用途で再利用されているためGC対策として意味を成していません。<br>
#私の環境ではif(szVal[i]=='-')のあたりで上書きされていました。<br>
正しく対策するには内部値を使用し終わった後にRB_GC_GUARDを置く必要があると思います。</p>
<p>以下で直ることを確認しました。</p>
<a name="Index-extbigdecimalbigdecimalc"></a>
<h1 >Index: ext/bigdecimal/bigdecimal.c<a href="#Index-extbigdecimalbigdecimalc" class="wiki-anchor">¶</a></h1>
<p>--- ext/bigdecimal/bigdecimal.c (リビジョン 27662)<br>
+++ ext/bigdecimal/bigdecimal.c (作業コピー)<br>
@@ -2593,7 +2593,7 @@<br>
int sign=1;<br>
Real *vp = NULL;<br>
U_LONG mf = VpGetPrecLimit();</p>
<ul>
<li>volatile VALUE buf;</li>
</ul>
<ul>
<li>
<p>VALUE buf;</p>
<p>mx = (mx + BASE_FIG - 1) / BASE_FIG + 1; /* Determine allocation unit. <em>/<br>
if(szVal) {<br>
@@ -2720,6 +2720,7 @@<br>
vp->MaxPrec = mx; /</em> set max precision */<br>
VpSetZero(vp,sign);<br>
VpCtoV(vp, &(szVal[ipn]), ni, &(szVal[ipf]), nf, &(szVal[ipe]), ne);</p>
</li>
<li>
<p>RB_GC_GUARD(buf);<br>
return vp;<br>
}<br>
=end</p>
</li>
</ul>
Ruby master - Bug #3108 (Closed): locationが初期化前に参照されて落ちます。
https://redmine.ruby-lang.org/issues/3108
2010-04-07T19:33:57Z
tarui (Masaya Tarui)
tarui@prx.jp
<p>=begin<br>
method情報のlocationが初期化されないまま参照されて落ちる事があります。</p>
<p>C:/usr/lib/ruby/1.9.1/optparse.rb:513: [BUG] rb_gc_mark(): unknown data type 0x1<br>
0(00F1382C) non object<br>
ruby 1.9.2dev (2010-04-07 trunk 27244) [i386-mswin32_90]</p>
<h2>-- control frame ----------<br>
c:0010 p:---- s:0033 b:0033 l:000032 d:000032 CFUNC :attr_reader<br>
c:0009 p:0013 s:0029 b:0029 l:000028 d:000028 CLASS C:/usr/lib/ruby/1.9.1/optpa<br>
rse.rb:513<br>
c:0008 p:0312 s:0027 b:0027 l:000026 d:000026 CLASS C:/usr/lib/ruby/1.9.1/optpa<br>
rse.rb:511<br>
c:0007 p:0009 s:0016 b:0016 l:000015 d:000015 TOP C:/usr/lib/ruby/1.9.1/optpa<br>
rse.rb:204<br>
c:0006 p:---- s:0014 b:0014 l:000013 d:000013 FINISH<br>
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :require<br>
c:0004 p:0023 s:0008 b:0008 l:000007 d:000007 TOP C:/usr/lib/ruby/1.9.1/un.rb<br>
:28<br>
c:0003 p:---- s:0006 b:0006 l:000005 d:000005 FINISH<br>
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 CFUNC :require<br>
c:0001 p:0000 s:0002 b:0002 l:000dc4 d:000dc4 TOP</h2>
<p>-- Ruby level backtrace information ----------------------------------------<br>
C:\usr\bin\ruby:0:in <code>require' C:/usr/lib/ruby/1.9.1/un.rb:28:in </code><top (required)>'<br>
C:/usr/lib/ruby/1.9.1/un.rb:28:in <code>require' C:/usr/lib/ruby/1.9.1/optparse.rb:204:in </code><top (required)>'<br>
C:/usr/lib/ruby/1.9.1/optparse.rb:511:in <code><class:OptionParser>' C:/usr/lib/ruby/1.9.1/optparse.rb:513:in </code><a href="class:List" class="external">class:List</a>'<br>
C:/usr/lib/ruby/1.9.1/optparse.rb:513:in `attr_reader'</p>
<p>原因はvm_method.c:286でlocationに値を入れる前にrb_ary_new3経由でGCが呼ばれる事があるためです。</p>
<p>Patchは多分こんなものでしょうか。</p>
<blockquote>
<p>svn diff<br>
Index: vm_method.c<br>
===================================================================<br>
--- vm_method.c (リビジョン 27249)<br>
+++ vm_method.c (作業コピー)<br>
@@ -280,6 +280,7 @@<br>
case VM_METHOD_TYPE_ATTRSET:<br>
case VM_METHOD_TYPE_IVAR:<br>
def->body.attr.id = (ID)opts;</p>
</blockquote>
<ul>
<li>
<pre><code> def->body.attr.location = Qfalse;
th = GET_THREAD();
cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (cfp && (line = rb_vm_get_sourceline(cfp))) {
</code></pre>
</li>
</ul>
<p>=end</p>