Bug #6764

IO#read(size, buf) causes can't set length of shared string in trunk (2.0.0dev)

Added by Hiroshi Nakamura almost 3 years ago. Updated over 2 years ago.

[ruby-core:46586]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
ruby -v:ruby 2.0.0dev (2012-07-11 trunk 36357) [i686-linux] Backport:

Description

=begin
http://travis-ci.org/#!/nahi/httpclient/jobs/1842569

Error: test_post_with_custom_multipart_and_file(TestHTTPClient)
RuntimeError: can't set length of shared string
/home/vagrant/builds/nahi/httpclient/lib/httpclient/http.rb:561:in read'
558:
559: def dump_file(io, dev)
560: buf = ''
=> 561: while !io.read(@chunk_size, buf).nil?
562: dev << buf
563: end
564: end
/home/vagrant/builds/nahi/httpclient/lib/httpclient/http.rb:561:in
dump_file'
/home/vagrant/builds/nahi/httpclient/lib/httpclient/http.rb:483:in block in dump'
/home/vagrant/builds/nahi/httpclient/lib/httpclient/http.rb:480:in
each'
/home/vagrant/builds/nahi/httpclient/lib/httpclient/http.rb:480:in dump'
/home/vagrant/builds/nahi/httpclient/lib/httpclient/http.rb:896:in
dump'
/home/vagrant/builds/nahi/httpclient/lib/httpclient/session.rb:612:in block in query'
/home/vagrant/.rvm/rubies/ruby-head/lib/ruby/2.0.0/timeout.rb:68:in
timeout'
/home/vagrant/.rvm/rubies/ruby-head/lib/ruby/2.0.0/timeout.rb:99:in timeout'
/home/vagrant/builds/nahi/httpclient/lib/httpclient/session.rb:610:in
query'
/home/vagrant/builds/nahi/httpclient/lib/httpclient/session.rb:161:in query'
/home/vagrant/builds/nahi/httpclient/lib/httpclient.rb:1060:in
do_get_block'
/home/vagrant/builds/nahi/httpclient/lib/httpclient.rb:869:in block in do_request'
/home/vagrant/builds/nahi/httpclient/lib/httpclient.rb:956:in
protect_keep_alive_disconnected'
/home/vagrant/builds/nahi/httpclient/lib/httpclient.rb:870:in do_request'
/home/vagrant/builds/nahi/httpclient/lib/httpclient.rb:756:in
request'
/home/vagrant/builds/nahi/httpclient/lib/httpclient.rb:666:in post'
/home/vagrant/builds/nahi/httpclient/test/test_httpclient.rb:769:in
block in test_post_with_custom_multipart_and_file'
/home/vagrant/builds/nahi/httpclient/test/test_httpclient.rb:765:in open'
/home/vagrant/builds/nahi/httpclient/test/test_httpclient.rb:765:in
test_post_with_custom_multipart_and_file'
=end

fix_read_buf.patch Magnifier (2.78 KB) Hiroshi Shirosaki, 09/15/2012 09:04 PM

Associated revisions

Revision 36980
Added by Nobuyoshi Nakada over 2 years ago

io.c: io_set_read_length

  • io.c (io_set_read_length): if the read length equals to the buffer string size then nothing to do. or ensure the string modifiable before setting the length only when the former is shorter. based on the patch in by Hiroshi Shirosaki. [Bug #6764]

Revision 36980
Added by Nobuyoshi Nakada over 2 years ago

io.c: io_set_read_length

  • io.c (io_set_read_length): if the read length equals to the buffer string size then nothing to do. or ensure the string modifiable before setting the length only when the former is shorter. based on the patch in by Hiroshi Shirosaki. [Bug #6764]

History

#1 Updated by Yui NARUSE almost 3 years ago

  • Status changed from Open to Assigned

This report is not contain small reproducible program.
Why don't you introduce ruby-zip/zlib's case?

#2 Updated by Hiroshi Nakamura almost 3 years ago

On Sun, Jul 22, 2012 at 2:32 AM, naruse (Yui NARUSE) naruse@airemix.jp wrote:

This report is not contain small reproducible program.
Why don't you introduce ruby-zip/zlib's case?

Indeed I should have tried. Let me try.

Here's one likely caused by the same bug:
https://github.com/aussiegeek/rubyzip/issues/38

#3 Updated by Hiroshi Shirosaki over 2 years ago

I see this bug with rubyzip. I tried to create a patch.

#4 Updated by Nobuyoshi Nakada over 2 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36980.
Hiroshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


io.c: io_set_read_length

  • io.c (io_set_read_length): if the read length equals to the buffer string size then nothing to do. or ensure the string modifiable before setting the length only when the former is shorter. based on the patch in by Hiroshi Shirosaki. [Bug #6764]

Also available in: Atom PDF