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

RULE-25-21, others: Consider something like a library TracesToExplicit<T> #848

Open
MichaelRFairhurst opened this issue Jan 27, 2025 · 0 comments
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address enhancement New feature or request Impact-Low

Comments

@MichaelRFairhurst
Copy link
Contributor

Affected rules

  • RULE-25-21
  • Likely others, haven't researched

Description

Rule 25-21 requires that the atomic_*_explicit operations use the memory order memory_order_seq_cst.

It would probably be overly restrictive to require an explicit inline written memory_order_seq_cst at the call site. However, it's probably too accepting to merely allow any dynamically computed value. Ideally, we can support basic indirection like variable assignment, parameter values, function calls/returns, and report cases that don't trace back to an acceptable root.

Doing this as a typical flow analysis is backwards. We can easily track flow from memory_order_seq_cst exprs to atomic_*_explicit calls, but the existence of such a flow doesn't preclude that invalid values also flow to the call. Alternatively, there are potential performance issues if we consider all exprs which are not memory_order_seq_cst to be sources in the flow analysis.

Wouldn't be terribly hard to write a library such as TracesToExplicit<T> that is a very simple global flow analysis made for this purpose, starting from sinks and doing only very obvious backwards tracking of values through function calls and variable assignments. If that doesn't track back to an acceptable value, we can report it. Ideally we can report it as a path-problem though this makes such a library more complex to implement.

@MichaelRFairhurst MichaelRFairhurst added Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address enhancement New feature or request Impact-Low labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address enhancement New feature or request Impact-Low
Projects
None yet
Development

No branches or pull requests

1 participant