Skip to content
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

Unclear whether or not libloading wrapper struct should have publicly accessible fields #1937

Closed
Cldfire opened this issue Dec 2, 2020 · 1 comment

Comments

@Cldfire
Copy link
Contributor

Cldfire commented Dec 2, 2020

#1931 changed the visibility of all the function pointer fields in the generated libloading wrapper struct from private to public.

However, in #1846 (comment), a convincing argument was made that these fields should remain private for safety reasons.

#1931 doesn't seem to discuss the safety concerns; I'm just wondering what the thought process was there 🙂

@emilio
Copy link
Contributor

emilio commented Dec 2, 2020

This was intentional. The main reason is that:

  • If you don't do this then we can't call varargs functions at all.
  • It complicated the code having to add an extra wrapper struct just to check if a function was correctly loaded.

Calling the public version of the symbol and grabbing a reference to it that outlives the Library is unsafe, so users are at their own risk if using that, and I think that's fine, but let me know if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants