Skip to content

Commit

Permalink
SPARK-5984: Fix TimSort bug causes ArrayOutOfBoundsException
Browse files Browse the repository at this point in the history
  • Loading branch information
hotou committed Feb 28, 2015
1 parent 479a106 commit 4d95f75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
import java.util.*;

/**
* This codes generates a int array which fails the standard TimSort, Borrowed from
* the reporter of this bug.
* This codes generates a int array which fails the standard TimSort.
*
* The blog that reported the bug
* http://www.envisage-project.eu/timsort-specification-and-verification/
*
* The algorithms to reproduce the bug is obtained from the reporter of the bug
* https://github.com/abstools/java-timsort-bug
*
* Licensed under Apache License 2.0
* https://github.com/abstools/java-timsort-bug/blob/master/LICENSE
*/
public class TestTimSort {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ class SorterSuite extends FunSuite {
}
}

test("bug of TimSort") {
// http://www.envisage-project.eu/timsort-specification-and-verification/
test("SPARK-5984 TimSort bug") {
val data = TestTimSort.getTimSortBugTestSet(67108864)
new Sorter(new IntArraySortDataFormat).sort(data, 0, data.length, Ordering.Int)
(0 to data.length - 2).foreach(i => assert(data(i) <= data(i+1)))
(0 to data.length - 2).foreach(i => assert(data(i) <= data(i + 1)))
}

/** Runs an experiment several times. */
Expand Down

0 comments on commit 4d95f75

Please sign in to comment.