Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112018-12-27T04:45:28ZRuby Issue Tracking System
Redmine Ruby master - Bug #15468 (Closed): Net::Protocol::BufferedIO#write raises NoMethodError when send...https://bugs.ruby-lang.org/issues/154682018-12-27T04:45:28Zeitoball (Eito Katagiri)eitoball@gmail.com
<p>ruby-2.6.0で大きなJSON文字列をNet::HTTPでPOSTすると以下のように NoMothodError が発生するようになりました。</p>
<pre><code>$ ruby -rnet/http -rjson -v -e "Net::HTTP.post(URI('http://httpbin.org/post'), { text: 'あ'*100_000 }.to_json, 'Content-Type' => 'application/json')"
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
Traceback (most recent call last):
19: from -e:1:in `<main>'
18: from lib/ruby/2.6.0/net/http.rb:500:in `post'
17: from lib/ruby/2.6.0/net/http.rb:605:in `start'
16: from lib/ruby/2.6.0/net/http.rb:920:in `start'
15: from lib/ruby/2.6.0/net/http.rb:502:in `block in post'
14: from lib/ruby/2.6.0/net/http.rb:1281:in `post'
13: from lib/ruby/2.6.0/net/http.rb:1493:in `send_entity'
12: from lib/ruby/2.6.0/net/http.rb:1479:in `request'
11: from lib/ruby/2.6.0/net/http.rb:1506:in `transport_request'
10: from lib/ruby/2.6.0/net/http.rb:1506:in `catch'
9: from lib/ruby/2.6.0/net/http.rb:1507:in `block in transport_request'
8: from lib/ruby/2.6.0/net/http/generic_request.rb:123:in `exec'
7: from lib/ruby/2.6.0/net/http/generic_request.rb:189:in `send_request_with_body'
6: from lib/ruby/2.6.0/net/protocol.rb:247:in `write'
5: from lib/ruby/2.6.0/net/protocol.rb:265:in `writing'
4: from lib/ruby/2.6.0/net/protocol.rb:248:in `block in write'
3: from lib/ruby/2.6.0/net/protocol.rb:275:in `write0'
2: from lib/ruby/2.6.0/net/protocol.rb:275:in `each_with_index'
1: from lib/ruby/2.6.0/net/protocol.rb:275:in `each'
lib/ruby/2.6.0/net/protocol.rb:280:in `block in write0': undefined method `bytesize' for nil:NilClass (NoMethodError)
</code></pre>
<p>理由は、Net::Protocol::BufferedIO#write0で、String#[]で送信されていない文字列を求める際に文字列にマルチバイト文字が含まれているとIO#write_nonblockで返ってくる送信されたバイト数が文字数を超えるため、nilになるためだと考えています。<a href="https://github.com/ruby/ruby/pull/2058" class="external">https://github.com/ruby/ruby/pull/2058</a> を送ってみました。</p> Ruby master - Bug #12434 (Rejected): Marshal.dump does not dump some numbers as Fixnumhttps://bugs.ruby-lang.org/issues/124342016-05-28T12:56:00Zeitoball (Eito Katagiri)eitoball@gmail.com
<p><code>Marshal.dump</code> dumps numbers between 1073741824 and 4294967295 and between -4294967296 and -1073741825 as <code>Bignum</code>, but I think that those numbers should be dumped as <code>Fixnum</code>.</p>
<pre><code>$ ./ruby --disable-gems -e'p Marshal.load("\x04\bi\x04\x00\x00\x00\x40")'
1073741824
$ ./ruby --disable-gems -e'p Marshal.dump(1073741824)'
"\x04\bl+\a\x00\x00\x00@"
$ ./ruby --disable-gems -e'p Marshal.load("\x04\bi\xfc\x00\x00\x00\x00")'
-4294967296
$ ./ruby --disable-gems -e'p Marshal.dump(-4294967296)'
"\x04\bl-\b\x00\x00\x00\x00\x01\x00"
</code></pre>
<p>I created proposed patch and submit pull request to <a href="https://github.com/ruby/ruby/pull/1366" class="external">https://github.com/ruby/ruby/pull/1366</a></p> Backport192 - Backport #3896 (Closed): Bus error in ObjectSpace.count_objects_sizehttps://bugs.ruby-lang.org/issues/38962010-10-02T02:31:00Zeitoball (Eito Katagiri)eitoball@gmail.com
<p>=begin<br>
Hello,</p>
<p>ObjectSpace.count_objects_size causes a bus error in ruby-1.9.2.</p>
<blockquote>
<p>ruby -robjspace -ve "ObjectSpace.count_objects_size"<br>
ruby 1.9.2p7 (2010-09-29 revision 29373) [i386-darwin9.8.0]<br>
-e:1: [BUG] Bus Error</p>
</blockquote>
<p>The following patch should solve this issue.</p>
<p>diff --git a/gc.c b/gc.c<br>
index 25fcc3d..564d260 100644<br>
--- a/gc.c<br>
+++ b/gc.c<br>
@@ -1145,7 +1145,7 @@ rb_data_typed_object_alloc(VALUE klass, void *datap, const<br>
size_t<br>
rb_objspace_data_type_memsize(VALUE obj)<br>
{</p>
<ul>
<li>if (RTYPEDDATA_P(obj)) {</li>
</ul>
<ul>
<li>if (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj)->dsize) {<br>
return RTYPEDDATA_TYPE(obj)->dsize(RTYPEDDATA_DATA(obj));<br>
}<br>
else {</li>
</ul>
<p>The trunk version does not have this issue because it checks the existence of dsize function pointer.<br>
=end</p>