WikiSort icon indicating copy to clipboard operation
WikiSort copied to clipboard

Getting a crash in the Rotate function

Open michaeleisel opened this issue 7 years ago • 3 comments

The line that says Rotate(array, Range_length(range) - count, range, cache, cache_size); calls into memmove(&array[range2.end - Range_length(range1)], &array[range1.start], Range_length(range1) * sizeof(array[0])); with a range where the end is less than the beginning, so it causes a crash. Any ideas why? I'm building for the iOS architecture, and on there it appears that size_t is unsigned, is it signed for you?

michaeleisel avatar Mar 07 '17 08:03 michaeleisel

size_t is always an unsigned integer type, so the problem can't come from there.

Could you provide a full example that fails for you? Like, a way to generate the input with which you managed to make the algorithm crash? Now, I'm not the maintainer of this project, but I fear that my contributions might be the source of your problems...

Morwenn avatar Mar 07 '17 09:03 Morwenn

Every time I create a list of random integers, it happens. If you do the math in the function calling Rotate, you'll see that it's entirely possible to get a range where the end is less than the beginning.

michaeleisel avatar Mar 07 '17 09:03 michaeleisel

Oh, that's in the C version. Sorry, I only looked at the C++ one.

Morwenn avatar Mar 07 '17 10:03 Morwenn