Jefffrey opened a new issue, #12439:
URL: https://github.com/apache/arrow-rs/issues/12439

   ### Describe the bug
   
   finishing a listbuilder relies on unsafe code to skip validation as it 
relies on builder maintaining invariants:
   
   
https://github.com/apache/arrow-rs/blob/6ec6d4600293f4e759e878c9dcb08c1417bf9f88/arrow-array/src/builder/generic_list_builder.rs#L299-L301
   
   but we can break these invariants using safe code
   
   ### To Reproduce
   
   ```rust
   #[test]
   fn test123() {
       let mut builder = ListBuilder::new(crate::builder::StringBuilder::new());
       builder.values().append_value("1");
       builder.append(true);
   
       // reset offsets to 0
       builder.values().finish();
       builder.append(true);
   
       builder.values().append_value("1");
       builder.append(true);
   
       let array = builder.finish();
       // we now have invalid list array, offsets [0, 1, 0, 1]
       dbg!(array.offsets());
   }
   ```
   
   when run:
   
   ```bash
   running 1 test
   [arrow-array/src/builder/generic_list_builder.rs:878:9] array.offsets() = 
OffsetBuffer(
       ScalarBuffer(
           [
               0,
               1,
               0,
               1,
           ],
       ),
   )
   test builder::generic_list_builder::tests::test123 ... ok
   ```
   
   ### Expected behavior
   
   this should be caught, and either error earlier or somehow prevented from 
happening
   
   ### Additional context
   
   - same as https://github.com/apache/arrow-rs/issues/12395 but for lists
   
   ### Willingness to contribute
   
   I cannot contribute a fix for this bug at this time


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