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

[C++] Fix nullptr deference in ipc/reader.cc

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • None
    • 8.0.0
    • C++

    Description

      MinGW GCC catches this

      [20/278] Building CXX object src/arrow/CMakeFiles/arrow_shared.dir/Unity/unity_24_cxx.cxx.obj
      In file included from C:/msys64/home/User/arrow/build/cpp/src/arrow/CMakeFiles/arrow_shared.dir/Unity/unity_24_cxx.cxx:3:
      C:/msys64/home/User/arrow/cpp/src/arrow/ipc/reader.cc: In member function 'virtual arrow::Result<std::function<arrow::Future<std::shared_ptr<arrow::RecordBatch> >()> > arrow::ipc::RecordBatchFileReaderImpl::GetRecordBatchGenerator(bool, const arrow::io::IOContext&, arrow::io::CacheOptions, arrow::internal::Executor*)':
      C:/msys64/home/User/arrow/cpp/src/arrow/ipc/reader.cc:1303:34: warning: 'this' pointer is null [-Wnonnull]
       1303 |       return cached_source->Cache({{0, footer_offset_}});
            |              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      In file included from C:/msys64/home/User/arrow/cpp/src/arrow/ipc/reader.h:28,
                       from C:/msys64/home/User/arrow/cpp/src/arrow/ipc/reader.cc:18,
                       from C:/msys64/home/User/arrow/build/cpp/src/arrow/CMakeFiles/arrow_shared.dir/Unity/unity_24_cxx.cxx:3:
      C:/msys64/home/User/arrow/cpp/src/arrow/io/caching.h:124:10: note: in a call to non-static member function 'arrow::Status arrow::io::internal::ReadRangeCache::Cache(std::vector<arrow::io::ReadRange>)'
        124 |   Status Cache(std::vector<ReadRange> ranges);
            |          ^~~~~ 

      This is pretty clearly wrong:

          std::shared_ptr<io::internal::ReadRangeCache> cached_source;
          if (coalesce && file_->supports_zero_copy()) {
            if (!owned_file_) return Status::Invalid("Cannot coalesce without an owned file");
            // Since the user is asking for all fields then we can cache the entire
            // file (up to the footer)
            return cached_source->Cache({{0, footer_offset_}});
          }
          return WholeIpcFileRecordBatchGenerator(std::move(state), std::move(cached_source),
                                                  io_context, executor);
      

      It seems ARROW-14577 removed one too many lines

      Attachments

        Issue Links

          Activity

            People

              lidavidm David Li
              lidavidm David Li
              Votes:
              0 Vote for this issue
              Watchers:
              4 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 - 1h
                  1h