HyukjinKwon opened a new pull request, #48753: URL: https://github.com/apache/arrow/pull/48753
### Rationale for this change The `ruby/red-arrow/test/test-ractor.rb` test hangs indefinitely on Windows, causing CI timeouts. The hang occurs when accessing `ChunkedArray#chunks` from, presumably, within a Ractor worker thread after the object has been frozen via [`Ractor.make_shareable`](https://docs.ruby-lang.org/en/master/Ractor.html#method-c-make_shareable). What I observe is that actually the custom `freeze` is not invoked in Ruby but invoked in C side alone, and for whatever reason `chunks` stays unset but `frozen` returns a true. Here is my speculation: When `ChunkedArray` is made shareable: 1. `Ractor.make_shareable` freezes the object without calling the custom `freeze` method 2. The custom `freeze` method (which pre-caches `@chunks`) is bypassed 3. `@chunks` remains uninitialized on a frozen object 4. When a Ractor worker calls `.chunks`, the code attempts `@chunks ||= chunks_raw.tap { ... }` 5. Assignment to `@chunks` on a frozen object causes the hang on Windows Disclaimer: I can't find the official behaviours to support my speculation. Note that Ruby 4.0's Ractor implementation remains [experimental](https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/). ### What changes are included in this PR? In `ruby/red-arrow/lib/arrow/chunked-array.rb`, added a guard in the `chunks` method to detect when an object is frozen without `@chunks` being initialized: ```ruby if frozen? && !instance_variable_defined?(:@chunks) return chunks_raw end ``` How this works: - This guard only activates when `Ractor.make_shareable` has frozen the object without invoking the custom `freeze` method - Normal usage (including explicit `.freeze()` calls) is unaffected because the custom `freeze` method pre-caches `@chunks` before freezing - The fix returns chunks directly without caching (caching is impossible on frozen objects) ### Are these changes tested? I will try to run the tests multiple times here to see if this fixes. ### Are there any user-facing changes? No breaking changes. The fix only affects the edge case of using `Ractor.make_shareable` with `ChunkedArray`, or rather when `frozen` is set` but `chunks` is unset. Normal usage patterns are completely unaffected: - Regular `.chunks` calls work identically - Properly frozen objects (via explicit `.freeze()`) work identically -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
