soasme / nim-markdown

A Beautiful Markdown Parser in the Nim World.

Home Page:https://www.soasme.com/nim-markdown/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to compile with threading turned on

JohnAD opened this issue · comments

The compiler message is:

/home/johnd/.nimble/pkgs/markdown-0.7.2/markdown.nim(2317, 6) Warning: 'applyInlineParsers' is not GC-safe as it performs an indirect call via 'inlineParser' [GcUnsafe2]

Looking into it, it makes sense. The MarkdownConfig.inlineParsers field holds a list of pointers to procedures held dynamically. In a single-threaded app, that works. I suspect, but can't confirm, the biggest problem is that the compiler can't check for GC safety because the proc references are only known at runtime.

Simply adding a {.gcsafe.} pragma might fix it if you are confident there won't be any runtime problems.

To replicate, add --threads:on to the nim compiler parameters and call markdown from a threaded-context such as a route in Jester.

commented

I'll look into it. Thanks for reporting.

I got the v0.8.0 changes and it all works great.

thanks!