import nativesockets raises error with enabled useNimRtl
Nim Version
Nim Compiler Version 2.0.2 [Linux: amd64] Compiled at 2023-12-15 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: c4c44d10df8a14204a75c34e499def200589cb7c active boot switches: -d:release
Description
# rtltest.nim
import nativesockets
echo "foo"
nim c -d:release -d:useRtl rtltest
Current Output
/home/carlo/.choosenim/toolchains/nim-2.0.2/lib/pure/nativesockets.nim(388, 52) template/generic instantiation from here
/home/carlo/.choosenim/toolchains/nim-2.0.2/lib/pure/nativesockets.nim(453, 18) Error: setSlice(ipStr) do:
7 .. pred(strAddrLen, 1) can have an unlisted effect: RootEffect
Expected Output
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
52820 lines; 0.844s; 71.148MiB peakmem; proj: /home/carlo/rtltest; out: /home/carlo/rtltest [SuccessX]
Known Workarounds
Use -d:useMalloc in both loading program and library and do not use -d:useNimRtl
Additional Information
No response
Experimented a bit, added tag RootException to getHostByAddr (lib/pure/nativesockets.nim line 395), which stopped that error, unsure what other effects that has.
After that, some code calling getCurrentException() produced getCurrentException() can raise an unlisted exception: Exception. So the flag useNimRtl seems to somehow change the behavior of the effects system in multiple ways. I compared with strictEffects but the latter compiled all my code normally.
See also https://github.com/nim-lang/Nim/issues/23162 https://github.com/nim-lang/Nim/pull/23163
Added a workaround to description (Use -d:useMalloc in both loading program and library and do not use -d:useNimRtl)
@ringabout Thanks for the connect! These seem like the same problem. They should be easy enough to fix but I feel a bit clueless to where to start to look.