1. [SPARK-25081][CORE] Nested spill in ShuffleExternalSorter should not (details)
Commit 04c652064861720d991675b7f5b53f2bbca9d14d by zsxwing
[SPARK-25081][CORE] Nested spill in ShuffleExternalSorter should not
access released memory page
## What changes were proposed in this pull request?
This issue is pretty similar to
"allocateArray" in
may trigger a spill and cause ShuffleInMemorySorter access the released
`array`. Another task may get the same memory page from the pool. This
will cause two tasks access the same memory page. When a task reads
memory written by another task, many types of failures may happen. Here
are some examples I  have seen:
- JVM crash. (This is easy to reproduce in a unit test as we fill newly
allocated and deallocated memory with 0xa5 and 0x5a bytes which usually
points to an invalid memory address)
- java.lang.IllegalArgumentException: Comparison method violates its
general contract!
- java.lang.NullPointerException at
- java.lang.UnsupportedOperationException: Cannot grow BufferHolder by
size -536870912 because the size after growing exceeds size limitation
This PR resets states in `ShuffleInMemorySorter.reset` before calling
`allocateArray` to fix the issue.
## How was this patch tested?
The new unit test will make JVM crash without the fix.
Closes #22062 from zsxwing/SPARK-25081.
Authored-by: Shixiong Zhu <> Signed-off-by: Shixiong
Zhu <>
(cherry picked from commit f5aba657396bd4e2e03dd06491a2d169a99592a7)
Signed-off-by: Shixiong Zhu <>
The file was addedcore/src/test/scala/org/apache/spark/shuffle/sort/ShuffleExternalSorterSuite.scala
The file was modifiedcore/src/main/java/org/apache/spark/shuffle/sort/ (diff)