-
Notifications
You must be signed in to change notification settings - Fork 24
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
Support environments without MessageChannel or worker_threads #51
Support environments without MessageChannel or worker_threads #51
Conversation
Don't have any issues with this. Will let @emilbayes get his thoughts in. |
@emilbayes Regarding the convo on Discord, I haven't come across any equivalent memory freeing APIs in React-Native, sadly. It might be worth it to revisit once they have support for ArrayyBuffers in their bridging API (which is likely a long ways away). |
@RangerMauve I think I might have confused on discord, the intention here is just to make the underlying ArrayBuffer inaccessible, not exactly to free it :) |
@emilbayes Yeah, I don't think RN provides anything special for that, sadly. 😅 Are there any APIs in ArrayBuffer itself that can make that work? |
Yeah there’s https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel but I guess RN doesn’t have that? |
@emilbayes No, I don't think it does, sadly. It doesn't have support for workers or anything of the sort, doesn't have that as a global, and I don't think there are any built in modules which provide that functionality. 😅 |
@emilbayes Updated the PR per your comments so that memory gets zeroed even if it can't be freed. You mentioned that you're not keen on merging due to the possiblity of "use after free" vulns. This wouldn't introduce them into Node.js or Browsers, and I think most of the libraries that'd be using this functionality would be targeting those environments too, and would reduce that risk. This would enable the library to be used in React-Native and JS environments that are neither Node.js or web browsers, and while it's not ideal, I don't think there's any way to do memory freeing in React-Native at the moment. I'd be happy to send a PR to add that in as soon as a way is found, but it would be nice to have even a non-ideal solution in the meantime. 😁 |
Part of #48
Fixes #47
This doesn't provide an alternative implementation for sodium_free, but it prevents runtime and compile-time errors in RN and node 10