Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
prasad83 opened this issue Oct 12, 2023 · 0 comments

Comments

@prasad83
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant