NVIDIA / NVIDIA/cccl

UBSan complains about device_vector::operator[] calls from host

Open
#715 1 comment 0 reactions 0 assignees View on GitHub
thrust
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

To reproduce :

main.cu :
```
#include
#include
#include

int main(void) {
thrust::device_vector D = std::vector{1,2,3};
std::cout << D[0] << std::endl;
return 0;
}
```

Compiled with:
`/usr/local/cuda-10.1/bin/nvcc main.cu -Xcompiler=-fsanitize=undefined`

causes following errors at run-time :
```
~/p/t/thrust ❯❯❯ ./a.out
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/detail/reference.inl:105:43: runtime error: reference binding to null pointer of type 'struct execution_policy'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/select_system.inl:89:36: runtime error: reference binding to null pointer of type 'struct execution_policy_base'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/detail/execution_policy.h:58:39: runtime error: reference binding to null pointer of type 'struct tag'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/select_system.inl:89:43: runtime error: reference binding to null pointer of type 'struct tag'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/detail/reference.inl:105:52: runtime error: reference binding to null pointer of type 'const struct tag'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/detail/reference.inl:133:9: runtime error: reference binding to null pointer of type 'struct tag'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/detail/reference.inl:137:38: runtime error: reference binding to null pointer of type 'struct execution_policy_base'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/detail/reference.inl:137:17: runtime error: reference binding to null pointer of type 'struct execution_policy'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/get_value.h:51:57: runtime error: reference binding to null pointer of type 'struct policy2'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/cross_system.h:51:55: runtime error: reference binding to null pointer of type 'struct policy1'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/internal/copy_cross_system.h:213:40: runtime error: reference binding to null pointer of type 'struct execution_policy_base'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/internal/copy_cross_system.h:213:27: runtime error: reference binding to null pointer of type 'struct execution_policy'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/internal/copy_cross_system.h:103:33: runtime error: reference binding to null pointer of type 'struct execution_policy_base'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/internal/copy_cross_system.h:103:20: runtime error: reference binding to null pointer of type 'struct execution_policy'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/util.h:53:31: runtime error: reference binding to null pointer of type 'struct execution_policy_base'
/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/util.h:53:18: runtime error: reference binding to null pointer of type 'struct execution_policy'
1
```

Nvcc version : V10.1.168
Thrust version : 1.9.5

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.