marcomq / nimview

A Nim/Webview based helper to create Desktop/Server applications with Nim/C/C++ and HTML/CSS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SIGSEGV after ~254 times calling "callFrontendJs" / "callJs" when threads enabled and using "--gc:refc"

marcomq opened this issue · comments

Nimview applications consistently crash when using the desktop mode on linux after calling about 243 times "callFrontendJs". This only happens in Nimview 0.3.2, as the function previously had issues. This doesn't happen on windows.
There is a SIGSEGV: Illegal stroage access. (Attempt to read from nil?)
image

This happens in Nim 1.4 and Nim 1.6, on linux and on windows in release mode.

Workaround:
Either not using "callFrontendJs" or using --gc:orc --deepCopy:on as compile option.
Both seems to successfully fix the crashes.

Only happens on linux and on windows with -d:release when default gc is used.
No issue anymore when compiling with threads:off, -d:useWebviewSingleThreaded or when using --gc:orc --deepCopy:on.

Edit:
I'm currently not working on this anymore as this seems to be hard to fix (for me).
This is most likely connected to the (old) Nim garbage collector and some unsafe calls to a global "var" from thread.

Resolved it by refactoring globals and storage.
Will be resolved in 0.4.1

Only happens when threads are enabled and default gc is used. Workaround: use --gc:orc

Found some issue when using single-thread and httpserver mode. Fixed for current main branch.

This is probably not fixable in any easy way.
I added a warning in "callJs" if threads are active and orc/arc is not the current gc/mm.

Closing this as there probably won't be any fix in future.