[ruby-core:126200] [Ruby Bug#22219] IO::Buffer#free, #resize and #transfer should raise FrozenError if the receiver is frozen
Issue #22219 has been reported by himura467 (Akito Shitara). ---------------------------------------- Bug #22219: IO::Buffer#free, #resize and #transfer should raise FrozenError if the receiver is frozen https://bugs.ruby-lang.org/issues/22219 * Author: himura467 (Akito Shitara) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Currently `IO::Buffer#free`, `#resize` and `#transfer` can be called even if the receiver is frozen. All three release, reallocate or hand away the memory the buffer references, so they change the state of the buffer. Therefore it seems a bug to me, and these methods should raise `FrozenError` if the receiver is frozen. ```ruby # Current IO::Buffer.new(4).freeze.free # succeeds, the buffer becomes null IO::Buffer.new(4).freeze.resize(8) # succeeds, the memory is reallocated IO::Buffer.new(4).freeze.transfer # succeeds, the receiver becomes null # Expected IO::Buffer.new(4).freeze.free # raise FrozenError IO::Buffer.new(4).freeze.resize(8) # raise FrozenError IO::Buffer.new(4).freeze.transfer # raise FrozenError ``` Methods to fix: * `IO::Buffer#free` * `IO::Buffer#resize` * `IO::Buffer#transfer` -- https://bugs.ruby-lang.org/
Issue #22219 has been updated by himura467 (Akito Shitara). ### PR for `IO::Buffer#free` and `IO::Buffer#resize`: https://github.com/ruby/ruby/pull/18129 for `IO::Buffer#transfer`: https://github.com/ruby/ruby/pull/18130 ---------------------------------------- Bug #22219: IO::Buffer#free, #resize and #transfer should raise FrozenError if the receiver is frozen https://bugs.ruby-lang.org/issues/22219#change-118285 * Author: himura467 (Akito Shitara) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Currently `IO::Buffer#free`, `#resize` and `#transfer` can be called even if the receiver is frozen. All three release, reallocate or hand away the memory the buffer references, so they change the state of the buffer. Therefore it seems a bug to me, and these methods should raise `FrozenError` if the receiver is frozen. ```ruby # Current IO::Buffer.new(4).freeze.free # succeeds, the buffer becomes null IO::Buffer.new(4).freeze.resize(8) # succeeds, the memory is reallocated IO::Buffer.new(4).freeze.transfer # succeeds, the receiver becomes null # Expected IO::Buffer.new(4).freeze.free # raise FrozenError IO::Buffer.new(4).freeze.resize(8) # raise FrozenError IO::Buffer.new(4).freeze.transfer # raise FrozenError ``` Methods to fix: * `IO::Buffer#free` * `IO::Buffer#resize` * `IO::Buffer#transfer` -- https://bugs.ruby-lang.org/
participants (1)
-
himura467 (Akito Shitara)