Morwenn / cpp-sort

Sorting algorithms & related tools for C++14
MIT License
621 stars 57 forks source link

Out-of-bound access in grail_sorter #183

Closed Morwenn closed 3 years ago

Morwenn commented 3 years ago

When running the test suite with MSVC in Debug mode, some grail_sorter tests failed because of the creation of out-of-bounds iterators.

353 - every random-access sorter with stable_adapter - cppsort::grail_sorter<> (Failed)
407 - test random-access sorters with all_equal distribution - cppsort::grail_sorter<> (Failed)
408 - test random-access sorters with all_equal distribution - cppsort::grail_sorter< cppsort::utility::dynamic_buffer<cppsort::utility::sqrt> > (Failed)
445 - test sorter with alternating_16_values distribution - cppsort::grail_sorter<> (Failed)
446 - test sorter with alternating_16_values distribution - cppsort::grail_sorter< cppsort::utility::dynamic_buffer<cppsort::utility::sqrt> > (Failed)
651 - test sorter with shuffled_16_values distribution - cppsort::grail_sorter<> (Failed)
652 - test sorter with shuffled_16_values distribution - cppsort::grail_sorter< cppsort::utility::dynamic_buffer<cppsort::utility::sqrt> > (Failed)

There is a clear pattern here: grail_sorter fails when there are lots of equivalent elements, which means that the culprit is likely in strategy 2 and/or strategy 3.