Project

General

Profile

Actions

Bug #19084

closed

Using `IO::Buffer` to change an extended String affects other Strings sharing the same buffer

Added by jemmai (Jemma Issroff) about 2 years ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:110514]

Description

When two extended Strings share a buffer, and one String's buffer changes, it currently affects the other String's buffer.

Here is a snippet to demonstrate this:

string = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

IO::Buffer.for(string) do |buffer|
  buffer.set_value(:U8, 0, "*".ord)
end

other_string[0] == "a"
# => false

Here is a PR which adds the above example as a test, and is currently failing CI.

(cc @ioquatix (Samuel Williams))

Actions #1

Updated by jemmai (Jemma Issroff) about 2 years ago

  • ruby -v set to 3.1.2
Actions #2

Updated by jemmai (Jemma Issroff) about 2 years ago

  • ruby -v changed from 3.1.2 to master
Actions #5

Updated by ioquatix (Samuel Williams) over 1 year ago

  • Status changed from Open to Closed
  • Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: REQUIRED, 3.2: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago

  • Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: REQUIRED, 3.2: REQUIRED to 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: REQUIRED, 3.2: DONE

ruby_3_2 c911cbd6c3dcc80def61ab48be1815cd910fc91b merged revision(s) bd786e78969f9d4a8699376ceafe10934b6ad533.

Updated by usa (Usaku NAKAMURA) over 1 year ago

  • Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: REQUIRED, 3.2: DONE to 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: DONE, 3.2: DONE

ruby_3_1 3799270ec27b1267cd9923dae00bcb3955f7e061 merged revision(s) bd786e78969f9d4a8699376ceafe10934b6ad533.

Actions

Also available in: Atom PDF

Like2
Like0Like0Like0Like0Like0Like0Like0