summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharles Blake <cb@cblake.net>2018-06-13 10:36:47 -0400
committerCharles Blake <cb@cblake.net>2018-06-13 10:36:47 -0400
commited4f1f4c4368238efc1686189e04e87b419e276a (patch)
tree637e0181b3b6d00f1d92acd11ac480aab7bad284
parentcd65ef0056c48ba06922aeec49bb0bd5c9d68fb9 (diff)
downloadNim-ed4f1f4c4368238efc1686189e04e87b419e276a.tar.gz
hotfix 3221ac094398492e09ea618638204793b0990eca broke gc:regions/aka gc:stack by
underallocating for sequences of any type larger than 1 byte.  This does the
necessary multiply to restore basic functionality.
-rw-r--r--lib/system/mmdisp.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim
index 2c9b1e502..b33ca93f2 100644
--- a/lib/system/mmdisp.nim
+++ b/lib/system/mmdisp.nim
@@ -562,7 +562,8 @@ else:
 when not declared(nimNewSeqOfCap):
   proc nimNewSeqOfCap(typ: PNimType, cap: int): pointer {.compilerproc.} =
     when defined(gcRegions):
-      result = newStr(typ, cap, ntfNoRefs notin typ.base.flags)
+      let s = mulInt(cap, typ.base.size)  # newStr already adds GenericSeqSize
+      result = newStr(typ, s, ntfNoRefs notin typ.base.flags)
     else:
       let s = addInt(mulInt(cap, typ.base.size), GenericSeqSize)
       when declared(newObjNoInit):