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

Check for lock-acquiring-temporaries unused across function call #37

Open
JosephCottam opened this issue Dec 8, 2023 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@JosephCottam
Copy link
Collaborator

A potentail lamellar-lint: Try to detect when a temporary holds a lock but that temporary is never used again.

async fn do_stuff(table: LocalLockArray) {
   let values = table.read_local_data().await;
   let v = values[0];
   do_other_stuff(table);
}

If do_other_stuff wants to write to table, it will be blocked because the read_lock is held until do_stuff finishes. It would be nice to have a lint that (1) knows what functions grab locks and (2) indicates when those locks probably aren't needed after a certain point (and suggests the temporary be explicitly dropped).

@JosephCottam JosephCottam added the enhancement New feature or request label Dec 8, 2023
@JosephCottam JosephCottam self-assigned this Dec 8, 2023
@JosephCottam
Copy link
Collaborator Author

Discussion with @rdfriese , the idea of only suggesting if the locked structure is passed to another context. However, there might be difficulty around alias detection...

async fn do_stuff(table: LocalLockArray) {
   let values = table.read_local_data().await;
   let v = values[0];

   let table2 = table;
   do_other_stuff(table2);
}

Not sure when the linter runs, but if the de-aliasing isn't run yet this case would be harder to catch.

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

No branches or pull requests

1 participant