From: "luke-gru (Luke Gruber) via ruby-core" Date: 2023-01-24T17:57:26+00:00 Subject: [ruby-core:112013] [Ruby master Bug#19375] File objects are currently shareable, as are other extension objects that shouldn't be. Issue #19375 has been updated by luke-gru (Luke Gruber). Subject changed from File objects are currently shareable to File objects are currently shareable, as are other extension objects that shouldn't be. The issue is with `Ractor.make_shareable` The same issue occurs with Dir, Tempfile, IO objects, the ENV hash. StringIO and CSV have this problem too. Sockets I think have the issue. For example, the issue with StringIO is that it needs an initialize_clone method that dup's the string. The underlying issue, though, is that it's a TypedData and doesn't store its internals in instance variables to be checked by the sharing logic. ```ruby require 'stringio' str = "string".dup stringio = StringIO.new(str) rs = 100.times.map do Ractor.new do strio = receive p strio.string.object_id end end p stringio.string.object_id rs.each do |r| r.send(stringio) end rs.each(&:take) ``` ---------------------------------------- Bug #19375: File objects are currently shareable, as are other extension objects that shouldn't be. https://bugs.ruby-lang.org/issues/19375#change-101446 * Author: luke-gru (Luke Gruber) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I don't know the internals of file.c but I don't think files are thread-safe. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/