Project

General

Profile

Actions

Bug #21212

open

IO::Buffer can be freed while its slice is locked

Added by hanazuki (Kasumi Hanazuki) 1 day ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-04-01T16:11:01Z master 30e5e7c005) +PRISM [x86_64-linux]
[ruby-core:121507]

Description

buffer = IO::Buffer.new(100)
slice = buffer.slice

buffer.locked do
  buffer.free rescue p $!  #=> IO::Buffer::LockedError (expected)
end

slice.locked do
  p slice.locked?  #=> true (expected)
  p buffer.locked?  #=> false (what should this be?)

  slice.free rescue p $!  #=> IO::Buffer::LockedError (expected)

  buffer.free  # Should we allow this?

  slice.set_value(:U8, 0, 42)  # raises IO::Buffer::InvalidatedError (surprising!)
end

No data to display

Actions

Also available in: Atom PDF

Like0