StarlingMonkey icon indicating copy to clipboard operation
StarlingMonkey copied to clipboard

Review and fix potential `url` instance memory leaks

Open andreiltd opened this issue 1 year ago • 2 comments

It's unclear how these url instances are dropped, if at all:

https://github.com/bytecodealliance/StarlingMonkey/blob/main/builtins/web/url.cpp#L364 https://github.com/bytecodealliance/StarlingMonkey/blob/main/builtins/web/url.cpp#L748 https://github.com/bytecodealliance/StarlingMonkey/blob/main/host-apis/wasi-0.2.0/host_api.cpp#L665

andreiltd avatar Feb 17 '25 11:02 andreiltd

Building on #212, I'm working on a Rust based host API implementation as a way to support the upcoming WASIp3 async without having to use C APIs (that aren't even supported by wit-bindgen yet.)

As part of that, I'm integrating CXX support. Perhaps we should change the existing crates to be based on CXX instead of the hodgepodge of hand-written APIs that I put together ages ago?

tschneidereit avatar Feb 17 '25 19:02 tschneidereit

Do you mean this: https://github.com/dtolnay/cxx ? If so, yes we could then return unique_ptr from Rust, that would solve the issue here. BTW, I remember one of the annoyances of working with cxx was that it used exceptions to model returning the Result from C++ to Rust with no option to disable exceptions. I'm not sure if this is going to be issue for us.

andreiltd avatar Feb 17 '25 19:02 andreiltd