From 9f9fa2c62c6c0b388cd0e9677ac1c2b4529146b7 Mon Sep 17 00:00:00 2001 From: Tomasz Bekas Date: Wed, 7 Aug 2024 13:25:50 +0200 Subject: [PATCH] Minimized example --- codex/erasure/asyncbackend.nim | 18 ++++--- config.nims | 2 +- tests/codex/extract_gc_bug.nim | 73 +++++++++++++++++++++++++ tests/codex/macro.nim | 52 ++++++++++++++++++ tests/codex/takspool_gc_bug.nim | 96 +++++++++++++++++++++++++++++++++ tests/codex/tp_example.nim | 42 +++++++++++++++ 6 files changed, 274 insertions(+), 9 deletions(-) create mode 100644 tests/codex/extract_gc_bug.nim create mode 100644 tests/codex/macro.nim create mode 100644 tests/codex/takspool_gc_bug.nim create mode 100644 tests/codex/tp_example.nim diff --git a/codex/erasure/asyncbackend.nim b/codex/erasure/asyncbackend.nim index 51db65e6..d31627f6 100644 --- a/codex/erasure/asyncbackend.nim +++ b/codex/erasure/asyncbackend.nim @@ -10,6 +10,7 @@ import std/sequtils import std/sugar import std/macros +import std/importutils import pkg/taskpools import pkg/taskpools/flowvars @@ -38,13 +39,14 @@ import pkg/taskpools/flowvars, pkg/taskpools/ast_utils - when (NimMajor,NimMinor,NimPatch) >= (1,6,0): import std/[isolation, tasks] export isolation else: import pkg/taskpools/shims_pre_1_6/tasks +privateAccess Task + import std/[cpuinfo, atomics, macros] @@ -212,14 +214,14 @@ proc decodeTask(args: DecodeTaskArgs, odata: seq[seq[byte]], oparity: seq[seq[by var ptrsParity: seq[pointer] for i in 0.. 0: - ptrsParity.add(unsafeAddr oparity[i][0]) - else: + if (unsafeAddr oparity[i]).isNil: + # echo "oparity is Nil " & $i ptrsParity.add(unsafeAddr oparity) + else: + if oparity[i].len > 0: + ptrsParity.add(unsafeAddr oparity[i][0]) + else: + ptrsParity.add(unsafeAddr oparity) echo "bef unsafe hash of data " & unsafeHashOf(ptrsData, odata.mapIt(it.len)) echo "bef unsafe hash of parity " & unsafeHashOf(ptrsParity, oparity.mapIt(it.len)) diff --git a/config.nims b/config.nims index 45830fad..de7d744a 100644 --- a/config.nims +++ b/config.nims @@ -65,7 +65,7 @@ else: --tlsEmulation:off --threads:on ---opt:speed +--opt:none --excessiveStackTrace:on # enable metric collection --define:metrics diff --git a/tests/codex/extract_gc_bug.nim b/tests/codex/extract_gc_bug.nim new file mode 100644 index 00000000..f79837a4 --- /dev/null +++ b/tests/codex/extract_gc_bug.nim @@ -0,0 +1,73 @@ +import std/[isolation, macros, sequtils,tasks] +import std/importutils +import system/ansi_c + +privateAccess Task + +const size = 10000 + +proc someTask(input: seq[seq[int]]) = + var sum = 0.int + + for i in 0..= (1,6,0): + import std/[isolation, tasks] + export isolation +else: + import pkg/taskpools/shims_pre_1_6/tasks + + +proc someTask(input: seq[seq[byte]]): byte = + var sum = 0.byte + + for i in 0..