Repository: spark
Updated Branches:
  refs/heads/master 2bc1c9515 -> 6d2379b3b


[SPARK-18485][CORE] Underlying integer overflow when create 
ChunkedByteBufferOutputStream in MemoryStore

## What changes were proposed in this pull request?

There is an underlying integer overflow when create 
ChunkedByteBufferOutputStream in MemoryStore. This PR provide a check before 
cast.

## How was this patch tested?

add new unit test

Author: uncleGen <[email protected]>

Closes #15915 from uncleGen/SPARK-18485.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/6d2379b3
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/6d2379b3
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/6d2379b3

Branch: refs/heads/master
Commit: 6d2379b3b762cdeff98db5ef4d963135c432580a
Parents: 2bc1c95
Author: uncleGen <[email protected]>
Authored: Sat Dec 17 13:19:30 2016 +0000
Committer: Sean Owen <[email protected]>
Committed: Sat Dec 17 13:19:30 2016 +0000

----------------------------------------------------------------------
 .../org/apache/spark/storage/memory/MemoryStore.scala     | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/6d2379b3/core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala
----------------------------------------------------------------------
diff --git 
a/core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala 
b/core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala
index fff2121..c08275c 100644
--- a/core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala
+++ b/core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala
@@ -331,7 +331,15 @@ private[spark] class MemoryStore(
     var unrollMemoryUsedByThisBlock = 0L
     // Underlying buffer for unrolling the block
     val redirectableStream = new RedirectableOutputStream
-    val bbos = new ChunkedByteBufferOutputStream(initialMemoryThreshold.toInt, 
allocator)
+    val chunkSize = if (initialMemoryThreshold > Int.MaxValue) {
+      logWarning(s"Initial memory threshold of 
${Utils.bytesToString(initialMemoryThreshold)} " +
+        s"is too large to be set as chunk size. Chunk size has been capped to 
" +
+        s"${Utils.bytesToString(Int.MaxValue)}")
+      Int.MaxValue
+    } else {
+      initialMemoryThreshold.toInt
+    }
+    val bbos = new ChunkedByteBufferOutputStream(chunkSize, allocator)
     redirectableStream.setOutputStream(bbos)
     val serializationStream: SerializationStream = {
       val autoPick = !blockId.isInstanceOf[StreamBlockId]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to