Morwenn / cpp-sort

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

SEGFAULT in Debug mode with MSVC in merge_insertion_sort #184

Closed Morwenn closed 3 years ago

Morwenn commented 3 years ago

merge_insertion_sort often segfaults with MSVC for an obscure reason. I managed to track the issue down to that specific line prior to the pairwise swaps:

auto end = has_stray ? std::prev(last) : last;

The line itself doesn't cause the segfault, but the destruction of end at the end of the algorithm scope does. I am so far unsure why, more tests are needed.

Morwenn commented 3 years ago

The previous commit wasn't a silver bullet, but it did help. There are no segfaults anymore, and we're down to two failing tests:

175 - test most sorters with no_post_iterator - cppsort::merge_insertion_sorter (Timeout)
759 - merge_insertion_sorter tests with projections (Timeout)

The timeouts make me suspect an infinite loop, but that's an investigation for another day. Unfortunately, the PRNG seed wasn't logged. Maybe we should log it directly from CMake in order to make extra sure.

Morwenn commented 3 years ago

It looks like the commit 11601542aca486b26b058d915ad1c7a0ead2a5c0 made the timeout issues disappear. I don't know how they're linked, but it doesn't seem extremely surprising that they are.

I'm gonna keep the issue opened a bit longer, and close it if the problem doesn't reappear.