Project

General

Profile

Actions

Bug #20933

closed

Unexpected IO::Buffer::MaskError in IO::Buffer#xor!

Added by agitter (Alexander Gitter) 22 days ago. Updated 19 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-12-06T12:47:35Z master 78614ee900) +PRISM [x86_64-linux]
[ruby-core:120120]

Description

The following script raises Mask overlaps source buffer! (IO::Buffer::MaskError) most of the time when running it on my Ubuntu 24.04 machine.
"Most of the time" means this sometimes (20% - 30%) works without issue.

a = IO::Buffer.new(1024 * 1024)
b = IO::Buffer.new(1024 * 1024)
a = IO::Buffer.new(1024 * 1024) # Removing this line makes this work much more reliably
a.xor!(b)

I'm guessing this is somehow related to these being MAPPED buffers - reducing the sizes to 1024 bytes also fixes the problem.

Updated by peterzhu2118 (Peter Zhu) 21 days ago

Thank you for this bug report. I have a fix here: https://github.com/ruby/ruby/pull/12284

Updated by agitter (Alexander Gitter) 21 days ago

I just gave your branch a quick test and can confirm it fixes this issue. Thank you!

Actions #3

Updated by peterzhu2118 (Peter Zhu) 19 days ago

  • Status changed from Open to Closed

Applied in changeset git|7341a4fc07ec8f12ff25538d39383ecf68a5f852.


[Bug #20933] Fix IO::Buffer overlap calculation

The allocated buffers may be consecutive memory addresses. This will mean
that b->base == a->base + a->size even though a and b are separate
buffers.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0