Skip to content

[BUG]: Host API memory access error in CUB's iterator test. #1893

Closed

Description

@alliepiper

Is this a duplicate?

Type of Bug

Silent Failure

Component

CUB

Describe the bug

https://github.com/NVIDIA/cccl/actions/runs/9606424817/job/26497170281?pr=1879

	compute-sanitizer --tool initcheck --check-device-heap yes --leak-check full --padding 512 --track-stream-ordered-races all --check-warpgroup-mma yes --require-cuda-init no --check-exit-code yes --error-exitcode 1 --nvtx true /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
========= COMPUTE-SANITIZER
========= Host API memory access error at host access to 0x7fb33ca00400 of size 32 bytes
=========     Uninitialized access at 0x7fb33ca00400 on access by cudaMemcpy source
=========     Saved host backtrace up to driver entry point at error
=========     Host Frame: [0x2e7d39]
=========                in /usr/lib/x86_64-linux-gnu/libcuda.so.1
=========     Host Frame:libcudart_static_e760a7280bc1af45ef561886abc194823c5edadb [0x2c3eb0]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:libcudart_static_901c335edfe2e89188fa6b8fe3e2a2194ad05bff [0x290109]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:cudaMemcpy [0x2eb946]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:void test_iterator<cub::CUB_200500_600_700_800_NS::ConstantInputIterator<signed char, long>, signed char>(cub::CUB_200500_600_700_800_NS::ConstantInputIterator<signed char, long>, thrust::THRUST_200500_600_700_800_NS::detail::vector_base<signed char, thrust::THRUST_200500_600_700_800_NS::mr::stateless_resource_allocator<signed char, c2h::checked_host_memory_resource> > const&) [0x15edd4]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:void C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_0<metal::list<signed char> >() [0x1257c6]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:Catch::RunContext::invokeActiveTestCase() [0x6dfa2]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) [0x86407]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:Catch::RunContext::runTest(Catch::TestCase const&) [0x8f0ea]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:Catch::Session::runInternal() [0x9956f]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:Catch::Session::run() [0x99b5d]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame:main [0x3b045]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator
=========     Host Frame: [0x23a8f]
=========                in /usr/lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:__libc_start_main [0x23b48]
=========                in /usr/lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:_start [0x64cf4]
=========                in /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator

How to Reproduce

compute-sanitizer --tool initcheck --check-device-heap yes --leak-check full --padding 512 --track-stream-ordered-races all --check-warpgroup-mma yes --require-cuda-init no --check-exit-code yes --error-exitcode 1 --nvtx true /home/coder/cccl/build/cuda12.4-gcc13/cub-cpp17/bin/cub.cpp17.test.iterator

Expected behavior

No diagnostics emitted.

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

Activity

  1. alliepiper commented on Nov 8, 2024

    @alliepiper
    ContributorAuthor

    I can reproduce this with a very simple program:

    #include <thrust/device_vector.h>
    #include <thrust/host_vector.h>
    
    #include <cub/iterator/constant_input_iterator.cuh>
    
    using T = cub::ConstantInputIterator<int>;
    // using T = int;
    
    int main()
    {
      T val(0);
      thrust::device_vector<T> d_vec(2, val);
      thrust::host_vector<T> h_vec = d_vec;
      return 0;
    }
    
    nvcc -lineinfo test.cu && compute-sanitizer --tool initcheck ./a.out 
    

    Swapping out T for int does not trigger warning. Will investigate the iterator implementation next.

  2. alliepiper commented on Nov 8, 2024

    @alliepiper
    ContributorAuthor

    Even simpler:

    #include <thrust/device_vector.h>
    #include <thrust/host_vector.h>
    
    struct foo
    {
      int val;
      ptrdiff_t offset;
    };
    
    using T = foo;
    // using T = cub::ConstantInputIterator<int>;
    
    int main()
    {
      T val{0, 1};
      thrust::device_vector<T> d_vec(2, val);
      thrust::host_vector<T> h_vec = d_vec;
      return 0;
    }
    

    It's the padding bits again. The error message suggests the entire 32-byte region is uninitialized, but it's just a portion of it. The diagnostic disappears when val and offset are both 8-byte types.

  3. alliepiper commented on Nov 15, 2024

    @alliepiper
    ContributorAuthor

    Suppressed several versions of this diagnostic for cub.test.iterator in #1879, all due to padding bits.

  4. moved this from Todo to Done in CCCLon Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions