[#82706] [Ruby trunk Bug#13851] getting "can't modify string; temporarily locked" on non-frozen instances — cardoso_tiago@...
Issue #13851 has been updated by chucke (Tiago Cardoso).
3 messages
2017/09/07
[#82853] [Ruby trunk Bug#13916] Race condition when sending a signal to a new fork — russell.davis@...
Issue #13916 has been reported by russelldavis (Russell Davis).
3 messages
2017/09/19
[#82892] [Ruby trunk Bug#13921] buffered read_nonblock doesn't work as expected using SSLSocket — cardoso_tiago@...
Issue #13921 has been updated by chucke (Tiago Cardoso).
3 messages
2017/09/20
[ruby-core:82676] [Ruby trunk Bug#13851] getting "can't modify string; temporarily locked" on non-frozen instances
From:
cardoso_tiago@...
Date:
2017-09-06 12:21:10 UTC
List:
ruby-core #82676
Issue #13851 has been updated by chucke (Tiago Cardoso).
> What operation(s) are you doing for "socket monitoring"?
i'm using plain IO.select. So the idea is, I have a selector thread, which pushes ready descriptors to a queue; other threads pull from that queue, and read/write from descriptors; if must wait, send them back to selector thread.
In the middle of this process, under significant load, I'm seeing the aforementioned error under the aforementioned read_nonblock API usage.
----------------------------------------
Bug #13851: getting "can't modify string; temporarily locked" on non-frozen instances
https://bugs.ruby-lang.org/issues/13851#change-66508
* Author: chucke (Tiago Cardoso)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.3.4
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
I'm doing some nonblocking IO, and using a local string for buffering to avoid allocations. Roughly the following
```ruby
class A
def initialize
@buffer = String.new("", encoding: Encoding::BINARY)
end
def read(io)
io.read_nonblock(16_384, @buffer, exception: false)
# do stuff...
@buffer.clear
end
```
It all goes smoothly, mostly... until I start getting arbitrary error when calling `#read_nonblock`. Here's an example backtrace:
```
DEBUG: can't modify string; temporarily locked- - - [30/Aug/2017:13:15:09 +0300] "GET / 1.0" 200 - 0.0000
DEBUG: <internal:prelude>:76:in `__read_nonblock'
DEBUG: <internal:prelude>:76:in `read_nonblock'
DEBUG: /Users/user/Projects/project:NN in `read``
....
```
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.
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.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>