nimwc Error: GC-safe as it accesses global using GC'ed memory or as it calls fn
prasad83 opened this issue · 0 comments
prasad83 commented
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.