Skip to content

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

@prasad83

Description

@prasad83

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions