Subodh-17 commented on code in PR #12293:
URL: https://github.com/apache/arrow-rs/pull/12293#discussion_r4598319411


##########
arrow-array/src/builder/fixed_size_binary_builder.rs:
##########
@@ -210,6 +210,13 @@ mod tests {
         assert_eq!(b"world", array.value(5));
     }
 
+    #[test]
+    fn test_fixed_size_binary_builder_rejects_wrapped_length() {
+        let mut b = FixedSizeBinaryBuilder::new(1);
+        let big = vec![0u8; (1usize << 32) + 1];

Review Comment:
   `let big = vec![0u8; (1usize << 32) + 1];` introduces two portability and 
resource issues:
   
   1. **32-bit compilation and execution failure:** On 32-bit platforms 
(`i686`, `wasm32`), `usize::BITS == 32`, so shifting by 32 is an invalid shift 
amount ($\ge 32$), causing compilation warnings/errors or a debug panic 
(`attempt to shift left by 32_usize, which would overflow`). In addition, 
`(1usize << 32) + 1` cannot fit in a 32-bit `usize` (`usize::MAX` is 
$4,294,967,295$), breaking 32-bit CI targets.
   2. **CI runner memory bloat:** Allocating a real $4.3\text{ GiB}$ 
($4,294,967,297$ bytes) zeroed heap vector in a unit test risks Out-Of-Memory 
(OOM) failures on memory-constrained CI runners (e.g., standard GitHub Actions 
runners with 7 GB RAM).
   
   **Recommendation:**
   Gate the test to 64-bit platforms with `#[cfg(target_pointer_width = "64")]` 
and `#[ignore]` (or mark with an appropriate feature gate so it is not run 
during default lightweight testing):
   
   ```rust
       #[test]
       #[cfg(target_pointer_width = "64")]
       #[ignore = "allocates >4GB to test 32-bit length truncation"]
       fn test_fixed_size_binary_builder_rejects_wrapped_length() {
           let mut b = FixedSizeBinaryBuilder::new(1);
           let big = vec![0u8; (1usize << 32) + 1];
           assert!(b.append_value(&big).is_err());
       }
   ```



-- 
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]

Reply via email to