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

Compile error if exported host functions overlap #189

Closed
leighmcculloch opened this issue Jul 9, 2022 · 3 comments
Closed

Compile error if exported host functions overlap #189

leighmcculloch opened this issue Jul 9, 2022 · 3 comments
Assignees

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Jul 9, 2022

@jonjove reported in Discord (ref) that we had some extern host fns overlapping which he fixed in #185.

I double checked and tried changing functions to use the same link names and the Rust compiler doesn't error at all.

This seems like quite a footgun. Of course if this happens with functions that behave wildly differently we're likely to notice. But for functions that behave somewhat similarly this could go unnoticed but have an enormous impact.

The host functions are generated by some macro rules in the common crate. We should find some way to ensure that their names are all unique.

cc @jayz22 @graydon @jonjove

@leighmcculloch
Copy link
Member Author

I don't love this idea, but a hack way to prevent this might be to write out some constants for each module and link name, since the compiler will error if there are constants with the same name. The error would not be particularly pretty, but any error is better than no error.

@leighmcculloch leighmcculloch changed the title Error if exported host functions overlap Compile error if exported host functions overlap Jul 9, 2022
@graydon graydon self-assigned this Jul 12, 2022
@anupsdf
Copy link
Contributor

anupsdf commented Jun 22, 2023

Setting target milestone to Post testnet after discussing with @graydon

@graydon
Copy link
Contributor

graydon commented Aug 14, 2023

since we use a proc macro now this is actually fairly trivial -- just check all the names when we read in the json file.

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

3 participants