Bug 798493: Incorrect updating of ByteArray when passed between worker threads (p=michsmi,r=jasowill)
authorDan Schaffer <Dan.Schaffer@adobe.com>
Tue, 09 Oct 2012 07:27:59 -0700
changeset 7564 f5191c18b0e4f3138931857a6c6fb666f8bb2824
parent 7563 c37e24c57796261722e5dc10124bf682ed11e503
child 7565 e7e08ab8fc7650e6cb4d83d326bc51bf15e8716a
push id4261
push userdschaffe@adobe.com
push dateTue, 09 Oct 2012 18:31:05 +0000
reviewersjasowill
bugs798493, 1122494, 1123072
Bug 798493: Incorrect updating of ByteArray when passed between worker threads (p=michsmi,r=jasowill) Integrate CL 1122494 CL@1123072
core/ByteArrayGlue.cpp
--- a/core/ByteArrayGlue.cpp
+++ b/core/ByteArrayGlue.cpp
@@ -180,16 +180,22 @@ namespace avmplus
         , m_gc(toplevel->core()->GetGC())
         , m_subscribers(m_gc, 0)
         , m_copyOnWriteOwner(NULL)
         , m_position(0)
         , m_buffer(source)
         , m_isShareable(shareable) 
         , m_isLinkWrapper(false)
     {
+		// Note that this constructor is only used when receiving a ByteArray from another worker
+		if (!m_isShareable) {
+			// If we made a copy of the ByteArray (i.e. it's not sharable), then we should account for the memory that we're about to receive.
+			// (until now, it's been sitting in the message queue, not assigned to any GC)
+			TellGcNewBufferMemory(m_buffer->array, m_buffer->capacity);
+		}
     }
 
 
     /* virtual */ void ByteArray::Buffer::destroy() 
     {
         if (array)
         {
             AvmAssert(capacity > 0);