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

Use FSA to check for thread-locals #151

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

jacob-hughes
Copy link
Collaborator

Finalizers in Alloy are run on a separate thread, so if a user tries to access a thread-local from within a drop method used as a finalizer it is almost certainly incorrect. This commit disallows this and emit an error when it happens.

if let ty::Adt(adt_def, ..) = self.kind() {
return tcx.get_diagnostic_item(sym::LocalKey).map_or(false, |t| adt_def.did() == t);
}
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll get a clippy warning telling you "just use false here? If so, please force push a fix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah. I don't think is setup to warn for this kind of thing on rustc, but I'll force push a fix anyway. For some reason just returning true/false without a return keyword and semicolon looks wrong to me, but it's not a hill I'll die on!

Finalizers in Alloy are run on a separate thread, so if a user tries to
access a thread-local from within a drop method used as a finalizer it
is almost certainly incorrect. This commit disallows this and emit an
error when it happens.
@jacob-hughes
Copy link
Collaborator Author

Force-pushed an update.

@ltratt ltratt added this pull request to the merge queue Dec 2, 2024
Merged via the queue into softdevteam:master with commit 66f0466 Dec 2, 2024
2 checks passed
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.

2 participants