Alessandro Molina created ARROW-12837:
-----------------------------------------

             Summary: [C++] Array::ToString() segfaults with null buffer.
                 Key: ARROW-12837
                 URL: https://issues.apache.org/jira/browse/ARROW-12837
             Project: Apache Arrow
          Issue Type: Bug
          Components: C++
    Affects Versions: 4.0.0
            Reporter: Alessandro Molina
            Assignee: Alessandro Molina


In some tests in the Arrow test suite there are cases where arrays are made 
without allocating real buffers of data, using {{Buffer}} of length 0 and with 
{{nullptr}} as their data.

In this cases the {{Array::ToString()}} does lead to segfault, at least for Int 
arrays.

{code}
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS 
(code=1, address=0x0)
    frame #0: 0x0000000101dac696 
libarrow.500.dylib`std::__1::enable_if<is_integer_type<arrow::NumericArray<arrow::Int32Type>::TypeClass>::value,
 arrow::Status>::type 
arrow::ArrayPrinter::WriteDataValues<arrow::NumericArray<arrow::Int32Type> 
>(this=0x00007ffeefbfea98, i=0)::'lambda'(long long)::operator()(long long) 
const at pretty_print.cc:152:73
   149    enable_if_integer<typename T::TypeClass, Status> 
WriteDataValues(const T& array) {
   150      const auto data = array.raw_values();
   151      // Need to upcast integers to avoid selecting operator<<(char)
-> 152      WriteValues(array, [&](int64_t i) { (*sink_) << 
internal::UpcastInt(data[i]); });
   153      return Status::OK();
   154    }
   155   
{code}

The issue can probably be worked around by checking if the data in the array is 
valid (at least for the most obvious cases, like NULLS or 0-length data) when 
building the string representation



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to