Bug #7957
closedrb_str_modify() does not prevent shared string from rb_str_set_len()
Description
unicorn HTTP chunk parser may raise "can't set length of shared string (RuntimeError)" in rb_str_set_len().
However, it does call rb_str_modify() before calling rb_str_set_len().
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 < unicorn_http.patch
make http # rebuild parser
ruby -I lib str_modify.rb # success (no output)
In my proposed patch, I call rb_str_resize() instead of rb_str_set_len() and that seems to
work around the issue. I even call rb_str_modify() an extra time before rb_str_set_len(),
but rb_str_set_len() still raises...
Files