-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
[0.x] Fix memory leaks of string buffers #320
[0.x] Fix memory leaks of string buffers #320
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :) Thank you!
After two years of managing this fork I think it’s fair to ask: can y’all please move to the 1.x/Rust-backed version? |
@jhawthorn Please, don’t interpret my comment as hostility. I literally had a panic attack after the PR merged because I wasn’t sure if the C-backed gem was still auto deploying or not; it’s been a while since the last cut and I didn’t know if I would get a ping about the gem not being released. I would like to remove the part of my brain that worries about this old gem being a part of your infrastructure. Let me know if there’s anything I can do to help update. |
Aw! S'all good, we were monitoring it on our end, and I would've done something had it failed. Sorry to give you feels about it.
We'd rather like to do so! However, John has Specific and Nuanced Views on the Safe Way to interact way Ruby from Rust, and they are incompatible with the magnus library due to, iirc, concerns around exception handling and memory management. I believe John's preference for talking to Rust is to use the FFI gem to interface with Since this is all unfunded, volunteer work, it's just not something we've had time to audit/propose to fix.
Durr, here's what - we'll fork this repo and get this dependency your hands. It won't happen right away, but I hereby relieve you of the burden of worrying about publishing this gem. |
Fabulous! I will delete the branch as soon as I am able. Y'all might also be interested in https://github.com/ioquatix/markly, which is a cut-off/fork from right before this moved to Rust.
Yeah, this is something I actually did before relying entirely on Magnus: write a little FFI .h and .c, and expose a C API in Rust. I'd be super curious to know what the issues are. I know various Shopify employees are also building out OSS Rust + Ruby tooling, so there's at least an opportunity for collaboration here. But you do you! Thanks for freeing us. |
Gimme a few weeks to push this around on my todo list before deleting anything 😅 🙇♀️. I'll let you know when it's totally off your hands! |
In a few places we were passing malloc'd memory to rb_str_new (and variants) and returning the resulting VALUE without freeing the passed C string buffer.
One of these leaks was introduced by #171 (we can see that some calls to
free
were lost in the rewrite), but others seem to predate that.After this change I'm able to run
ASAN_OPTIONS="detect_leaks=1" RUBY_FREE_AT_EXIT=1 bundle exec rake
with an ASAN-built Ruby without errors.cc @anticomputer @phillmv