From: Eric Wong Date: 2017-08-30T19:29:24+00:00 Subject: [ruby-core:82539] Re: [Ruby trunk Bug#13851] getting "can't modify string; temporarily locked" on non-frozen instances cardoso_tiago@hotmail.com wrote: > I can't unfortunately reproduce this in a deterministic way. I > can only say that the `read` routine is called in multiple > threads (different io's instances of that class). The errors > come seldom, however. That's not good, and reading prelude.rb, io.c and string.c; I'm not seeing how it's possible unless you have accidental sharing going on. Can you reproduce the problem with 2.4 or trunk? Even if not deterministic, can you write a standalone infinite loop which can eventually reproduce this? Another option may be to try thread-local storage for @buffer, instead, if you never need the data long-term. IME, it will save memory for C10K situations and help avoid accidental sharing bugs (if indeed your fault :) > I'm running ruby 2.3.4, and the frozen string literal is > activated for the file where the class is defined. I first > assumed that it was the buffer, but due to its initialization, > it should be marken as not-frozen. Right, I'm not seeing this, either... Btw, I prefer to use (since Ruby 2.0+): @buffer = ''.b Rather than: @buffer = String.new("", encoding: Encoding::BINARY) ...in your situation, as it is much shorter :) Unsubscribe: