Actions
Bug #21882
closedIO::Buffer#locked leaves the buffer locked when the block raises
Bug #21882:
IO::Buffer#locked leaves the buffer locked when the block raises
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [x86_64-linux]
Description
IO::Buffer#locked should unlock the buffer even after the block raises an exception.
buf = IO::Buffer.new(100)
buf.locked { fail } rescue nil
buf.locked { p :ok } # expected to print :ok, but actually raises a LockedError
Updated by hanazuki (Kasumi Hanazuki) 7 days ago
Updated by nobu (Nobuyoshi Nakada) 6 days ago
buf.locked {break} also leaves it locked.
Could you add a test for this case too?
Updated by hanazuki (Kasumi Hanazuki) 6 days ago
Thank you for your review, nobu. I added test cases for break and throw.
Updated by hanazuki (Kasumi Hanazuki) 2 days ago
- Status changed from Open to Closed
Applied in changeset git|b5ccab2093c9bb19ae8564a935e6fd72ec7354cc.
IO::Buffer#locked: Release lock even when the block raises (#16180)
IO::Buffer#locked: Release lock even when the block raises/breaks
Previously, IO::Buffer#locked leaks the lock when the block raises
an exception, or breaks.
Fixes: [Bug #21882]
Actions