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

[C++] alloc-dealloc-mismatch in s3fs.cc

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 3.0.0
    • 3.0.0
    • C++
    • Compile with clang memory sanitizer

    Description

      Checking

      https://github.com/apache/arrow/blob/256d0dc3f712154100aa6e0a610383b189008a83/cpp/src/arrow/filesystem/s3fs.cc#L611

      Aws::IOStreamFactory AwsWriteableStreamFactory(void* data, int64_t nbytes){
         return [=]() { return new StringViewStream(data, nbytes); };
      }
      

      Instead, there is supposed to be using `Aws::New` rather than c++'s own `new`

      Aws::IOStreamFactory AwsWriteableStreamFactory(void* data, int64_t nbytes) {
         return [=]() { return Aws::New<StringViewStream>("", data, nbytes); };
      }
      

      This is easy to be checked out when compiled with clang memory sanitizer.

      =================================================================
      ==148546==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x6110001f1e80
          #0 0xcac4e2 in free /local/mnt/workspace/bcain_0721/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:124:3
          #1 0x7ff039bb10f0 in Aws::Utils::Stream::ResponseStream::~ResponseStream() (/opt/dependency-clang-x86_64-Linux/package/lib/libaws-cpp-sdk-core.so+0xc20f0)
          #2 0x7ff03fe05157 in Aws::S3::Model::GetObjectResult::~GetObjectResult() /opt/dependency-clang-x86_64-Linux/package/include/aws/s3/model/GetObjectResult.h:30:20
          #3 0x7ff03fe038dd in Aws::Utils::Outcome<Aws::S3::Model::GetObjectResult, Aws::S3::S3Error>::~Outcome() /opt/dependency-clang-x86_64-Linux/package/include/aws/core/utils/Outcome.h:25:15
      
      0x6110001f1e80 is located 0 bytes inside of 256-byte region [0x6110001f1e80,0x6110001f1f80)
      allocated by thread T0 here:
          #0 0xcdbd52 in operator new(unsigned long) /local/mnt/workspace/bcain_0721/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_new_delete.cc:106:3
          #1 0x7ff03fdd9af0 in dbcommon::AwsWriteableStreamFactory(void*, long)::$_0::operator()() const /home/gpadmin/dev/hornet-opensource/dbcommon/src/dbcommon/filesystem/s3/s3-file-system.cc:157:25
          #2 0x7ff03fdd9aac in decltype(std::__1::forward<dbcommon::AwsWriteableStreamFactory(void*, long)::$_0&>(fp)()) std::__1::__invoke<dbcommon::AwsWriteableStreamFactory(void*, long)::$_0&>(dbcommon::AwsWriteableStreamFactory(void*, long)::$_0&) /opt/clang/include/c++/v1/type_traits:4353:1
          #3 0x7ff03fdd9a3c in std::__1::basic_iostream<char, std::__1::char_traits<char> >* std::__1::__invoke_void_return_wrapper<std::__1::basic_iostream<char, std::__1::char_traits<char> >*>::__call<dbcommon::AwsWriteableStreamFactory(void*, long)::$_0&>(dbcommon::AwsWriteableStreamFactory(void*, long)::$_0&) /opt/clang/include/c++/v1/__functional_base:318:16
          #4 0x7ff03fdd9a0c in std::__1::__function::__alloc_func<dbcommon::AwsWriteableStreamFactory(void*, long)::$_0, std::__1::allocator<dbcommon::AwsWriteableStreamFactory(void*, long)::$_0>, std::__1::basic_iostream<char, std::__1::char_traits<char> >* ()>::operator()() /opt/clang/include/c++/v1/functional:1527:16
          #5 0x7ff03fdd7248 in std::__1::__function::__func<dbcommon::AwsWriteableStreamFactory(void*, long)::$_0, std::__1::allocator<dbcommon::AwsWriteableStreamFactory(void*, long)::$_0>, std::__1::basic_iostream<char, std::__1::char_traits<char> >* ()>::operator()() /opt/clang/include/c++/v1/functional:1651:12
          #6 0x7ff039bb0fa2 in Aws::Utils::Stream::ResponseStream::ResponseStream(std::__1::function<std::__1::basic_iostream<char, std::__1::char_traits<char> >* ()> const&) (/opt/dependency-clang-x86_64-Linux/package/lib/libaws-cpp-sdk-core.so+0xc1fa2)
      
      SUMMARY: AddressSanitizer: alloc-dealloc-mismatch /local/mnt/workspace/bcain_0721/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:124:3 in free
      ==148546==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
      ==148546==ABORTING
      

      Attachments

        Issue Links

          Activity

            People

              chiyang10000 Wan Chiyang
              chiyang10000 Wan Chiyang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 24h
                  24h
                  Remaining:
                  Time Spent - 50m Remaining Estimate - 23h 10m
                  23h 10m
                  Logged:
                  Time Spent - 50m Remaining Estimate - 23h 10m
                  50m