Skip to content

Commit

Permalink
Add memory poisoning to the lookaside lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Dec 29, 2019
1 parent c9efb8b commit 1a3f990
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion weave/memory/lookaside_lists.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1a3f990

Please sign in to comment.