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

Fix drop order for Module fields #2806

Merged
merged 2 commits into from
Feb 25, 2022
Merged

Fix drop order for Module fields #2806

merged 2 commits into from
Feb 25, 2022

Conversation

Amanieu
Copy link
Contributor

@Amanieu Amanieu commented Feb 24, 2022

The field ordering here is actually significant because of the drop
order: we want to drop the artifact before dropping the engine.

The reason for this is that dropping the Artifact will de-register the
trap handling metadata from the global registry. This must be done before
the code memory for the artifact is freed (which happens when the store
is dropped) since there is a chance that this memory could be reused by
another module which will try to register its own trap information.

Note that in Rust, the drop order for struct fields is from top to
bottom: the opposite of C++.

In the future, this code should be refactored to properly describe the
ownership of the code and its metadata.

Fixes #2434

The field ordering here is actually significant because of the drop
order: we want to drop the artifact before dropping the engine.

The reason for this is that dropping the Artifact will de-register the
trap handling metadata from the global registry. This must be done before
the code memory for the artifact is freed (which happens when the store
is dropped) since there is a chance that this memory could be reused by
another module which will try to register its own trap information.

Note that in Rust, the drop order for struct fields is from top to
bottom: the opposite of C++.

In the future, this code should be refactored to properly describe the
ownership of the code and its metadata.

Fixes #2434
@Amanieu Amanieu requested a review from syrusakbary as a code owner February 24, 2022 22:14
@Amanieu Amanieu requested review from ptitSeb and syrusakbary and removed request for syrusakbary February 24, 2022 22:15
@Amanieu
Copy link
Contributor Author

Amanieu commented Feb 25, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Feb 25, 2022

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

Successfully merging this pull request may close these issues.

Failed to instantiate a deserialized Module compiled with the Dylib engine
3 participants