From 2b74bbba0e2a7c287098ea963b7bade0cf57ef35 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 30 Mar 2016 20:56:44 +0800 Subject: [PATCH 1/5] fix initAllocator not being called when defined(nogc) and not defined(useMalloc) else bottom is not properly initialized - running with sysAssert catches this issue nicely --- lib/system.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index fefabe53f3..ce32baf38b 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2564,10 +2564,14 @@ else: when not defined(JS): #and not defined(nimscript): {.push stack_trace: off, profiler:off.} + when not ( + defined(boehmgc) or + defined(gogc) or + (defined(nogc) and defined(useMalloc))): + proc initAllocator() {.inline.} + when not defined(nimscript) and not defined(nogc): proc initGC() - when not defined(boehmgc) and not defined(useMalloc) and not defined(gogc): - proc initAllocator() {.inline.} proc initStackBottom() {.inline, compilerproc.} = # WARNING: This is very fragile! An array size of 8 does not work on my From 3116744c86f37ac4e4e5fec3d6d1635304ed717f Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Thu, 25 Aug 2016 20:17:30 +0800 Subject: [PATCH 2/5] no allocator init for nimscript --- lib/system.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/system.nim b/lib/system.nim index ce32baf38b..da37512d63 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2565,6 +2565,7 @@ when not defined(JS): #and not defined(nimscript): {.push stack_trace: off, profiler:off.} when not ( + defined(nimscript) or defined(boehmgc) or defined(gogc) or (defined(nogc) and defined(useMalloc))): From 260e615017977592c4a165fc0289b5e77f182a64 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Thu, 25 Aug 2016 23:04:44 +0800 Subject: [PATCH 3/5] simplify initallocator conditions --- lib/system.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 6af5dc01ff..c97ccf4ebf 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2582,10 +2582,10 @@ else: when not defined(JS): #and not defined(nimscript): {.push stack_trace: off, profiler:off.} - when not defined(nimscript) and (not defined(nogc) or not defined(useMalloc)): + when not defined(nimscript): when not defined(gcStack): proc initGC() - when not defined(boehmgc) and not defined(gogc) and not defined(gcStack): + when not defined(boehmgc) and not defined(useMalloc) and not defined(gogc) and not defined(gcStack): proc initAllocator() {.inline.} proc initStackBottom() {.inline, compilerproc.} = From a65b44cae90b0b9f4edfad93922c12be957e513e Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Sat, 3 Sep 2016 10:56:27 +0800 Subject: [PATCH 4/5] one more fix condition --- lib/system.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index c97ccf4ebf..26feb5ce8c 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2582,10 +2582,11 @@ else: when not defined(JS): #and not defined(nimscript): {.push stack_trace: off, profiler:off.} - when not defined(nimscript): + when hasAlloc: when not defined(gcStack): proc initGC() - when not defined(boehmgc) and not defined(useMalloc) and not defined(gogc) and not defined(gcStack): + when not defined(boehmgc) and not defined(useMalloc) and + not defined(gogc) and not defined(gcStack): proc initAllocator() {.inline.} proc initStackBottom() {.inline, compilerproc.} = @@ -2603,7 +2604,6 @@ when not defined(JS): #and not defined(nimscript): when declared(setStackBottom): setStackBottom(locals) - when hasAlloc: var strDesc = TNimType(size: sizeof(string), kind: tyString, flags: {ntfAcyclic}) From 4435d83a885fb3bb7059f1758f20fee14d68a831 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 12 Oct 2016 21:32:15 +0800 Subject: [PATCH 5/5] run gctest for gc:none --- tests/testament/categories.nim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 3ed2f21961..2b0b55c0b6 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -115,6 +115,12 @@ proc dllTests(r: var TResults, cat: Category, options: string) = # ------------------------------ GC tests ------------------------------------- proc gcTests(r: var TResults, cat: Category, options: string) = + template testWithNone(filename: untyped) = + testSpec r, makeTest("tests/gc" / filename, options & + " --gc:none", cat, actionRun) + testSpec r, makeTest("tests/gc" / filename, options & + " -d:release --gc:none", cat, actionRun) + template testWithoutMs(filename: untyped) = testSpec r, makeTest("tests/gc" / filename, options, cat, actionRun) testSpec r, makeTest("tests/gc" / filename, options & @@ -144,6 +150,7 @@ proc gcTests(r: var TResults, cat: Category, options: string) = test "gcleak" test "gcleak2" test "gctest" + testWithNone "gctest" test "gcleak3" test "gcleak4" # Disabled because it works and takes too long to run: