Define explicit ownership for custom appenders and formatters
Add SharedLogState for synchronized value data and factories for independently owned appender state and captured formatter closures. Reject unsafe configuration state, update the test collector to value snapshots, and document the breaking APIs in version 3.0.0. Expand ORC ownership and sanitizer coverage and reject stale test executables.
This commit is contained in:
1 parent
851caef706
commit
b2d0e9dade
11 files changed
+808
-110
No files matched your search
@@ -0,0 +1,38 @@
|
||||
## Standalone reproduction of Nim 2.2.10's allocator sanitizer report.
|
||||
## No logging-library imports. All accesses to the shared sequence hold a lock.
|
||||
import std/[atomics, locks]
|
||||
|
||||
type AllocatorData = object
|
||||
lock: Lock
|
||||
entries: seq[int]
|
||||
total: int
|
||||
|
||||
var start: Atomic[bool]
|
||||
|
||||
proc withData(data: ptr AllocatorData,
|
||||
action: proc(entries: var seq[int]) {.gcsafe.}) =
|
||||
withLock data.lock:
|
||||
action(data.entries)
|
||||
inc data.total
|
||||
|
||||
proc append(data: ptr AllocatorData, value: int) =
|
||||
data.withData(proc(entries: var seq[int]) =
|
||||
entries.add(value)
|
||||
if entries.len >= 64: entries = @[])
|
||||
|
||||
proc worker(data: ptr AllocatorData) {.thread.} =
|
||||
while not start.load(): discard
|
||||
for i in 0 ..< 10_000: data.append(i)
|
||||
|
||||
proc runAllocatorRegression*() =
|
||||
var data: AllocatorData
|
||||
initLock(data.lock)
|
||||
defer: deinitLock(data.lock)
|
||||
var workers: array[4, Thread[ptr AllocatorData]]
|
||||
for thread in workers.mitems: createThread(thread, worker, addr data)
|
||||
start.store(true)
|
||||
joinThreads(workers)
|
||||
doAssert data.total == 40_000
|
||||
|
||||
when isMainModule:
|
||||
runAllocatorRegression()
|
||||
Reference in new issue
Block a user