nim-lang / redis

Official redis wrapper for Nim.
Other
128 stars 35 forks source link

Error while compiling with threads: 'evalMessageIter' is not GC-safe as it calls 'keys' #35

Open samsamros opened 1 year ago

samsamros commented 1 year ago

Context: compiling with latest nim version (1.7.1) and with the following: nim c --run -d:ssl -d:release -mm:orc --threads:on Error.nim

and initially got this error:

'evalMessageIter' is not GC-safe as it calls 'keys'

I began tracing the problem one by one until I found the culprit for my particular program.

Error: 'readArrayLinesIter' is not GC-safe as it calls 'readNext'

I went to the lines where the proc is defined in three diferent places. lines 262, 263 and 308 and added the {.gcsafe.} pragma to all and got the following:

Error: public implementation 'redis.readNext(r: AsyncRedis)' has non-public forward declaration at /home/.../.nimble/pkgs/redis-0.3.0/redis.nim(260, 6)

I added a to `proc readNext(r: AsyncRedis): Future[RedisList]` and got the following:

Error: public implementation 'redis.readNext(r: Redis)' has non-public forward declaration at /home/.../.nimble/pkgs/redis-0.3.0/redis.nim(259, 6)

So, also added another to this `proc readNext(r: Redis): RedisList`

The program finally compiled without issues and is working really well... so far. I'm still running tests to see how the program behaves, and perhaps someone else has run into this (maybe I'm doing something wrong?). I hope it helps.

PS thank you for taking the time to write this amazing code. it's beautiful