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

Add "typechecking" to DynamicLib #17833

Closed
kmcallister opened this issue Oct 7, 2014 · 3 comments
Closed

Add "typechecking" to DynamicLib #17833

kmcallister opened this issue Oct 7, 2014 · 3 comments
Labels
A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html

Comments

@kmcallister
Copy link
Contributor

We'd produce a metadata table with a TypeId hash for each exported symbol and check it in DynamicLibrary::symbol. The function will still need to be unsafe because there are plenty of ways to deliberately circumvent the check (collisions of the 64-bit hash, hex-editing the .so file, etc) but it will fix the poor user experience of accidental type mismatch when using plugins (in the case of rustc plugins, this is #14841).

We'll also have DynamicLibrary::raw_symbol which does no typecheck, gives an *mut u8, and can be used with non-Rust .so's.

I plan to work on this after #8157.

@kmcallister kmcallister added A-libs A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html labels Oct 7, 2014
@huonw
Copy link
Member

huonw commented Oct 7, 2014

Maybe DynamicLibrary could be kept separate and a higher-level one built in top? (E.g. DynamicLibrary & RustDynamicLibrary or CDynamicLibrary & DynamicLibrary.)

E.g. theoretically RustDynamicLibrary could check for validity/that's it's a rust library/read metadata when opening it, while this is not possible wit a non-Rust .so.

@kmcallister
Copy link
Contributor Author

Possibly over-engineered, but how about

pub struct DynamicLibrary<E> {
    extra: E,}

impl<E> DynamicLibrary<E> {}

pub struct RustLibrary {}

impl DynamicLibrary<RustLibrary> {}

@alexcrichton
Copy link
Member

This is unfortunately fairly unlikely to happen, and we're unlikely to stabilize DynamicLibrary as-is, so I'm going to close this as we're not tracking feature requests for various libs in this issue tracker.

lnicola pushed a commit to lnicola/rust that referenced this issue Aug 13, 2024
Reuse recursion limit as expansion limit

A configurable recursion limit was introduced by looking at the recursion_limit crate attribute. Instead of relying on a global constant we will reuse this value for expansion limit as well.

Addresses: rust-lang/rust-analyzer#8640 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html
Projects
None yet
Development

No branches or pull requests

3 participants