Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-10692

[Rust] Segfault while array buffer append

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 2.0.0
    • 3.0.0
    • Rust
    • Ubuntu 20.04. rustc-nightly,

    Description

      // src/buffer.rs:657
         
          /// Ensures that this buffer has at least `capacity` slots in this buffer. This will
          /// also ensure the new capacity will be a multiple of 64 bytes.
          ///
          /// Returns the new capacity for this buffer.
          pub fn reserve(&mut self, capacity: usize) -> Result<usize> {
              if capacity > self.capacity {
                  unsafe { memory :: reallocate(self.data, self.capacity, new_capacity) };
                  self.data = new_data as *mut u8;
                  self.capacity = new_capacity;
              }
              Ok(self.capacity)
          }

       
      Above code is not checking if new_data is null, which is causing segfault on following memcpy when reallocate failed.

      Attachments

        Issue Links

          Activity

            People

              jorgecarleitao Jorge Leitão
              niuzr Ziru Niu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 50m
                  2h 50m