You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "pitrou (via GitHub)" <gi...@apache.org> on 2024/06/13 12:04:43 UTC

[I] [C++] Potentially uninitialized variables [arrow]

pitrou opened a new issue, #42139:
URL: https://github.com/apache/arrow/issues/42139

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   I get these warnings when compiling in `RelWithDebInfo` mode. These are probably harmless but it would be good to silence them anyway:
   ```
   [265/572] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/c/bridge.cc.o
   /home/antoine/arrow/dev/cpp/src/arrow/c/bridge.cc: In member function 'arrow::Status arrow::{anonymous}::ArrayExporter::Export(const std::shared_ptr<arrow::ArrayData>&)':
   /home/antoine/arrow/dev/cpp/src/arrow/c/bridge.cc:540:33: warning: '<unnamed>.arrow::<unnamed>::ArrayExporter::export_.arrow::{anonymous}::ExportedArrayPrivateData::dictionary_' may be used uninitialized [-Wmaybe-uninitialized]
     540 |   ARROW_DEFAULT_MOVE_AND_ASSIGN(ExportedArrayPrivateData);
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~
   /home/antoine/arrow/dev/cpp/src/arrow/c/bridge.cc:620:68: note: '<anonymous>' declared here
     620 |       child_exporters_.emplace_back(ArrayExporter{device_interface_});
         |                                                                    ^
   [465/572] Building CXX object src/arrow/gpu/CMakeFiles/arrow-gpu-cuda-benchmark.dir/cuda_benchmark.cc.o
   /home/antoine/arrow/dev/cpp/src/arrow/gpu/cuda_benchmark.cc: In function 'void arrow::cuda::CudaBufferWriterBenchmark(benchmark::State&, int64_t, int64_t, int64_t)':
   /home/antoine/arrow/dev/cpp/src/arrow/gpu/cuda_benchmark.cc:42:35: warning: 'manager' may be used uninitialized [-Wmaybe-uninitialized]
      42 |   ABORT_NOT_OK(manager->GetContext(kGpuNumber).Value(&context));
         |                                   ^
   /home/antoine/arrow/dev/cpp/src/arrow/gpu/cuda_benchmark.cc:39:22: note: 'manager' was declared here
      39 |   CudaDeviceManager* manager;
         |                      ^~~~~~~
   ```
   
   ### Component(s)
   
   C++


-- 
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: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [C++] Potentially uninitialized variables [arrow]

Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on issue #42139:
URL: https://github.com/apache/arrow/issues/42139#issuecomment-2176588929

   btw this fixes the warning for the benchmark, I'll push a PR once I can reproduce the other and fix both:
   ```diff
   diff --git a/cpp/src/arrow/gpu/cuda_benchmark.cc b/cpp/src/arrow/gpu/cuda_benchmark.cc
   index 2787d10..3c4354b 100644
   --- a/cpp/src/arrow/gpu/cuda_benchmark.cc
   +++ b/cpp/src/arrow/gpu/cuda_benchmark.cc
   @@ -36,7 +36,7 @@ constexpr int64_t kGpuNumber = 0;
    static void CudaBufferWriterBenchmark(benchmark::State& state, const int64_t total_bytes,
                                          const int64_t chunksize,
                                          const int64_t buffer_size) {
   -  CudaDeviceManager* manager;
   +  CudaDeviceManager* manager = nullptr;;
      ABORT_NOT_OK(CudaDeviceManager::Instance().Value(&manager));
      std::shared_ptr<CudaContext> context;
      ABORT_NOT_OK(manager->GetContext(kGpuNumber).Value(&context));
   ```


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [C++] Potentially uninitialized variables [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on issue #42139:
URL: https://github.com/apache/arrow/issues/42139#issuecomment-2186689305

   Warnings like this typically depend on the compiler and compiler version, so providing reproducible instructions isn't easy. That said, they are easy to solve even without reproducing.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [C++] Potentially uninitialized variables [arrow]

Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on issue #42139:
URL: https://github.com/apache/arrow/issues/42139#issuecomment-2176586648

   @pitrou I can't seem to reproduce locally the first error on `bridge.cc` with `RelWithDebInfo`. I've tried different options and presets and I've been able to reproduce the:
   ```
   [721/735] Building CXX object src/arrow/gpu/CMakeFiles/arrow-gpu-cuda-benchmark.dir/cuda_benchmark.cc.o
   /home/raulcd/code/arrow/cpp/src/arrow/gpu/cuda_benchmark.cc: In function ‘void arrow::cuda::CudaBufferWriterBenchmark(benchmark::State&, int64_t, int64_t, int64_t)’:
   /home/raulcd/code/arrow/cpp/src/arrow/gpu/cuda_benchmark.cc:42:35: warning: ‘manager’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      42 |   ABORT_NOT_OK(manager->GetContext(kGpuNumber).Value(&context));
         |                                   ^
   [734/735] Install the project...
   ```
   Can you share how did you build to get the `c/bridge.cc` warning?
   BTW, I also got:
   ```
   [111/605] Building CXX object src/arrow/CMakeFiles/arrow_util.dir/util/compression.cc.o
   In file included from /home/raulcd/code/arrow/cpp/src/arrow/result.h:27,
                    from /home/raulcd/code/arrow/cpp/src/arrow/util/compression.h:26,
                    from /home/raulcd/code/arrow/cpp/src/arrow/util/compression.cc:18:
   /home/raulcd/code/arrow/cpp/src/arrow/util/compression.cc: In static member function ‘static arrow::Result<std::unique_ptr<arrow::util::Codec> > arrow::util::Codec::Create(arrow::Compression::type, const arrow::util::CodecOptions&)’:
   /home/raulcd/code/arrow/cpp/src/arrow/util/compression.cc:218:28: warning: ‘this’ pointer is null [-Wnonnull]
     218 |   RETURN_NOT_OK(codec->Init());
         |                 ~~~~~~~~~~~^~
   /home/raulcd/code/arrow/cpp/src/arrow/status.h:57:62: note: in definition of macro ‘ARROW_RETURN_NOT_OK’
      57 |     ::arrow::Status __s = ::arrow::internal::GenericToStatus(status); \
         |                                                              ^~~~~~
   /home/raulcd/code/arrow/cpp/src/arrow/util/compression.cc:218:3: note: in expansion of macro ‘RETURN_NOT_OK’
     218 |   RETURN_NOT_OK(codec->Init());
         |   ^~~~~~~~~~~~~
   [604/605] Install the project...
   ```
   Which probably should be fixed too.
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org