Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing tests with libstdc++ assertions due to unsigned overflow #570

Closed
AngryLoki opened this issue Jun 10, 2024 · 1 comment · Fixed by #575
Closed

Failing tests with libstdc++ assertions due to unsigned overflow #570

AngryLoki opened this issue Jun 10, 2024 · 1 comment · Fixed by #575

Comments

@AngryLoki
Copy link

Describe the bug
Hi, while testing with hardened libstdc++ (compiled with -D_GLIBCXX_ASSERTIONS), many tests rocPRIM failed with traceback like:

libstdc++.so.6!std::__glibcxx_assert_fail(char const*, int, char const*, char const*) (Unknown Source:0)
std::uniform_int_distribution<unsigned int>::param_type::param_type() (\usr\lib\gcc\x86_64-pc-linux-gnu\13\include\g++-v13\bits\uniform_int_dist.h:108)
std::uniform_int_distribution<unsigned int>::uniform_int_distribution() (\usr\lib\gcc\x86_64-pc-linux-gnu\13\include\g++-v13\bits\uniform_int_dist.h:145)
test_utils::generate_random_data_n<__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char> > >, int, int, std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul> >() (\var\tmp\portage\sci-libs\rocPRIM-6.1.1\work\rocPRIM-rocm-6.1.1\test\rocprim\test_utils_data_generation.hpp:262)
test_utils::get_random_data<unsigned char, int, int>(seed_type seed_value) (\var\tmp\portage\sci-libs\rocPRIM-6.1.1\work\rocPRIM-rocm-6.1.1\test\rocprim\test_utils_data_generation.hpp:354)
RocprimBlockLoadStoreClassTestsFirstPart_LoadStoreClass_Test<class_params<unsigned char, (rocprim::block_load_method)2, (rocprim::block_store_method)2, 512u, 1u> >::TestBody(class RocprimBlockLoadStoreClassTestsFirstPart_LoadStoreClass_Test<class_params<unsigned char, (rocprim::block_load_method)2, (rocprim::block_store_method)2, 512u, 1u> > * this) (\var\tmp\portage\sci-libs\rocPRIM-6.1.1\work\rocPRIM-rocm-6.1.1\test\rocprim\test_block_load_store.hpp:53)

where starting point is test_utils::get_random_data<Type>(size, -100, 100, seed_value);
and ending point is __glibcxx_assert(_M_a <= _M_b), where _M_a = 4294967196 and _M_b = 100.

I. e. tests try to build uniform_int_distribution<unsigned int> between -100 and 100, which results in implicit conversion, which results in undefined behavior.

Affected tests are:

  • RocprimBlockLoadStoreClassTestsFirstPart/23.LoadStoreClass
  • RocprimBlockSortMergeTestsIntegral/8.SortKeys
  • RocprimBlockShuffleTestsIntegral/8.BlockOffset
  • RocprimBlockSortBitonicTestsIntegral/8.SortKeys
  • DeviceBatchMemcpyTests/11.SizeAndTypeVariation
  • RocprimDeviceSortTests/0.SortKey
  • RocprimDeviceRunLengthEncode/3.Encode
  • RocprimDeviceUniqueByKeyTests/2.UniqueByKey

Some of them use unsigned short, some unsigned long long and so on. Replacing negative starting point with non-negative helps, but maybe you can provide a better solution?

Environment

  • rocPRIM 6.1.1
@Naraenda
Copy link
Member

We're tracking this internally. I'll try to get this in for 6.3, but it might slack to a patch bump. Idem for ROCm/rocThrust#420.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants