ThomasTJdev / nim_websitecreator

Nim fullstack website framework - deploy a website within minutes
https://nimwc.org
MIT License
176 stars 7 forks source link

nimwc Error: GC-safe as it accesses global using GC'ed memory or as it calls fn #146

Open prasad83 opened 11 months ago

prasad83 commented 11 months ago

With nim version 2.0

After fixing: (datetime2human MR) + (nim_websitecreator MR)

./nimwc gives the following error

std/asyncmacro(250, 31) Error: 'matchMatcher (Async)' is not GC-safe as it accesses 'storageEFS' which is a global using GC'ed memory

To fix this variable has to be declared as threadvar and initialized later (without using let)

var storageEFS* {.threadvar.}: string
storageEFS = block:
   ...
   path

./nimwc will now result in error

std/asyncmacro(250, 31) Error: 'matchMatcher (Async)' is not GC-safe as it calls 'sendEmailActivationManual'

To fix this proc has to marked as .gcsafe along with .async

proc sendEmailActivationManual*(email, userName, password, activateUrl, invitorName: string) {.async, gcsafe.} =

./nimwc will now result in error

std/asyncmacro(250, 31) Error: 'sendEmailActivationManual (Async)' is not GC-safe as it calls 'genEmailMessage'
proc genEmailMessage*(msgContent: string): string {.inline, .gcsafe.} =

If proc marked as gcsafe depends on global variable then they should be declared as {.threadvar.} and initialized safely.