Recently I was using Nim with a hybrid C++ app using the handy cppstl library. When I tried using the threading/channels I was running into either double free's or memory leaks. I think it was due to a combination of wasMoved and C++ destructors.
I'm curious if it's possible to get C++ objects to play nicely with wasMoved with the right dtors / move / copy constructors.
Obviously it's easier to do it with pure Nim objects, which is what I did. It was a bit tedious to convert back and forth, and I'm curious if it'd be possible.
--cc:clang -t:"-fsanitize=thread" -l:"-fsanitize=thread" -d:nosignalhandler
). Maybe there is an issue with C++ and wasMoved as well but the broken channel is probably the cause of this.I will share my experience with threading/channels It's certainly broken right now. You can verify that easily by running the example (including the clang ThreadSanitizer with
Thanks, are you using the standard channel impl? I'm using the threading/channels implementation, and it's worked fine for me. That -t:"-fsanitize=thread" looks handy though!
My issue was directly tied to using C++ in the channel. Just using Nim types worked fine, as was using C++ structs. But C++ vectors and other types gave errors with either double frees or a memory leak.
I'm guessing, but it seems like it's a combo with wasMoved. Also, isolate and unsafeIsolate both gave me errors with more C++ types, complaining about the copy operator.