From 961f87e1c5d0cbe312a02997123e65fc315afb06 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 21 Apr 2019 12:16:55 -0400 Subject: Fixes #2033, shared queue push bug (#2158) --- core/shared_queue.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'core/shared_queue.js') diff --git a/core/shared_queue.js b/core/shared_queue.js index 02aded748..aa3ff0aee 100644 --- a/core/shared_queue.js +++ b/core/shared_queue.js @@ -1,4 +1,20 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +/* +SharedQueue Binary Layout ++-------------------------------+-------------------------------+ +| NUM_RECORDS (32) | ++---------------------------------------------------------------+ +| NUM_SHIFTED_OFF (32) | ++---------------------------------------------------------------+ +| HEAD (32) | ++---------------------------------------------------------------+ +| OFFSETS (32) | ++---------------------------------------------------------------+ +| RECORD_ENDS (*MAX_RECORDS) ... ++---------------------------------------------------------------+ +| RECORDS (*MAX_RECORDS) ... ++---------------------------------------------------------------+ + */ (window => { const GLOBAL_NAMESPACE = "Deno"; @@ -69,7 +85,7 @@ let off = head(); let end = off + buf.byteLength; let index = numRecords(); - if (end > shared32.byteLength) { + if (end > shared32.byteLength || index >= MAX_RECORDS) { console.log("shared_queue.ts push fail"); return false; } @@ -141,6 +157,7 @@ setAsyncHandler, dispatch, sharedQueue: { + MAX_RECORDS, head, numRecords, size, -- cgit v1.2.3