-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NimYAML compatibility with ARC/ORC. #85
Comments
ARC is a bad idea for the YAML DOM since that can contain cycles. Generally I am not up-to-date with those newish Nim GC systems, so I can't quickly assess its impact on native serialization. Did you run tests with valgrind to check whether memory is properly managed? |
Well there's ORC as well, which is ARC with cycles. I ran Valgrind and had some memory leaks, but didn't try to investigate them yet. Is there any reason you used raw pointers for storing the source object? |
The
The last step never happened and so the temporary hack went the way of all temporary hacks and has been in the code base for years :). |
@flyx FYI - lexbase works with Nim's JS backend on devel and that will be in 1.4 :) |
As for the original topic: I would like NimYAML to fail at compile time if generated code is not guaranteed to not leak memory. This would mean that e.g. the DOM API should fail with a compile-time error if compiled with If there are any internal memory leaks using ARC/ORC, those should be addressed before officially supporting these GCs. I will look into removing the |
@flyx yeah, it's totally fine, ORC will (probably) be the new default GC in 1.4, not ARC. when defined(gcArc) and not defined(gcOrc):
{.error: "NimYAML only supports ORC because ARC can't deal with cycles".} |
@flyx also, an update - ORC will not be the default in 1.4, but I hope that we manage to get NimYAML to support it before ORC is made default in future Nim releases :) |
A lexer/parser rewrite has landed in Regarding your patch, only removing |
I disabled the DOM API for ARC. Current head now compiles and tests green with both ORC and ARC, the latter without the DOM API tests. Since I rewrote the parser, that part of your patch is obsolete. I am unsure whether the part of your patch for |
Patch to dom.nim is not needed anymore since sink inference is disabled for user code now. You can still add the changes if you want to make sure that if users want to use it with your lib - it works, but I don't think that it's such a big deal. (Try compiling with |
Hello! I've been testing a lot of Nim libraries with ARC/ORC, and NimYAML is one of them :) After nim-lang/Nim#15052 and some manual patching it seems to work fine with
--gc:orc --sinkInference:off
(sink inference can also be enabled if you add two {.nosinks.}`.Would you be interested in somehow adding these patches to NimYAML without breaking compatibility with older Nim versions? FYI - destructors are mapped to finalizers (but I think only on 1.2+), so we'll need to have more when branching.
The patch itself is https://gist.github.com/Yardanico/e03d29b4db56366543bbb01d935daa62 (you can ignore nosinks parts - they don't need to be added if you compile with
--sinkInference:off
). The main problem I solved there is that new Nim runtime (with ARC/destructors) can't map multiple finalizers, because destructors are type-bound. So I had to create two additional bool fields (I suppose we could replace them with just one isLexer, and check if it's true or false). With this patch NimYAML passed all tests for me with bothrefc
(default GC) andorc
on latest devel.The text was updated successfully, but these errors were encountered: