Bug #7957

rb_str_modify() does not prevent shared string from rb_str_set_len()

Added by Eric Wong about 1 year ago. Updated about 1 year ago.

[ruby-core:52876]
Status:Third Party's Issue
Priority:High
Assignee:Nobuyoshi Nakada
Category:core
Target version:2.1.0
ruby -v:ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux] Backport:

Description

unicorn HTTP chunk parser may raise "can't set length of shared string (RuntimeError)" in rbstrsetlen().
However, it does call rb
strmodify() before calling rbstrsetlen().

To reproduce:
git clone git://bogomips.org/unicorn
cd unicorn
gem install isolate # needed for unicorn dependencies
git reset --hard v4.6.1
make http # build HTTP parser (needs ragel installed: apt-get install ragel)
ruby -I lib str_modify.rb # failure, raises

apply unicorn_http.patch

patch -p1 < unicornhttp.patch
make http # rebuild parser
ruby -I lib str
modify.rb # success (no output)

In my proposed patch, I call rbstrresize() instead of rbstrsetlen() and that seems to
work around the issue. I even call rb
strmodify() an extra time before rbstrsetlen(),
but rbstrset_len() still raises...

str_modify.rb Magnifier - script to reproduce the issue (requires unicorn) (408 Bytes) Eric Wong, 02/25/2013 09:54 PM

unicorn_http.patch Magnifier - proposed patch to unicorn (931 Bytes) Eric Wong, 02/25/2013 09:54 PM

History

#1 Updated by Koichi Sasada about 1 year ago

  • Category set to core
  • Assignee set to Nobuyoshi Nakada
  • Priority changed from Normal to High
  • Target version set to 2.1.0

#2 Updated by Eric Wong about 1 year ago

I will try to make a standalone test case which does not depend on
the Ragel parser.

#3 Updated by Eric Wong about 1 year ago

sorry for the noise. It turns out unicorn has a build system bug.

#4 Updated by Usaku NAKAMURA about 1 year ago

  • Status changed from Open to Third Party's Issue

#5 Updated by Eric Wong about 1 year ago

This is definitely not a ruby bug, fixed in unicorn v4.6.2
(commit f7ee06592d7709e96f64efb5e7a9485b54415c9d)

Also available in: Atom PDF