From 1a3f99015d11f7506b809a8cfa04ee7cfa11fb67 Mon Sep 17 00:00:00 2001 From: mMay Date: Sun, 29 Dec 2019 22:58:50 +0100 Subject: [PATCH] Add memory poisoning to the lookaside lists --- weave/memory/lookaside_lists.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weave/memory/lookaside_lists.nim b/weave/memory/lookaside_lists.nim index bb3097e..7e076fb 100644 --- a/weave/memory/lookaside_lists.nim +++ b/weave/memory/lookaside_lists.nim @@ -6,7 +6,8 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - ../instrumentation/contracts + ../instrumentation/[contracts, sanitizers], + ./allocs type IntrusiveStackable* = concept x, type T @@ -69,12 +70,14 @@ func add*[T](lal: var LookAsideList[T], elem: sink T) {.inline.} = preCondition(not elem.isNil) elem.next = lal.top + poisonMemRegion(elem, sizeof(deref(T))) lal.top = elem lal.count += 1 proc popImpl[T](lal: var LookAsideList[T]): T {.inline.} = result = lal.top + unpoisonMemRegion(result, sizeof(deref(T))) lal.top = lal.top.next # result.next = nil - we assume it is being zero-ed