Skip to content

Refactor bot of threadJoins analysis to mean uncomputed#1977

Merged
sim642 merged 8 commits intomasterfrom
copilot/fix-invalid-widen-issue
Apr 8, 2026
Merged

Refactor bot of threadJoins analysis to mean uncomputed#1977
sim642 merged 8 commits intomasterfrom
copilot/fix-invalid-widen-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

The bu solver triggers Lattice.Invalid_widen when threadJoins is active because man.global tid returns bot() before contributions arrive — and MustThreadSet.bot() was {UnknownThread}. Widening then fails because leq doesn't treat UnknownThread as a universal element in the reversed lattice.

Core change

(* before *)
module MustThreadSet = SetDomain.Reverse (ThreadSet)

(* after *)
module MustThreadSet = SetDomain.Reverse (SetDomain.ToppedSet (ThreadIdDomain.FlagConfiguredTID) (struct let topname = "All Threads" end))
  • Removes UnknownThread from the element type entirely; elements are now FlagConfiguredTID.t
  • bot() becomes the proper Top sentinel (all threads must-joined = unreachable), not the semantically broken {UnknownThread}
  • Fixes leq / widening by eliminating the element that had no coherent must-join semantics

Copilot AI changed the title [WIP] Fix invalid widen after join with mhp and threadJoins domains Fix Invalid_widen in MustThreadSet by replacing Reverse(ThreadSet) with Reverse(ToppedSet(FlagConfiguredTID)) Apr 1, 2026
Copilot AI requested a review from michael-schwarz April 1, 2026 11:46
Comment thread src/analyses/threadJoins.ml Outdated
@michael-schwarz michael-schwarz requested a review from arkocal April 1, 2026 13:38
@michael-schwarz
Copy link
Copy Markdown
Member

This hopefully fixes all the issues in the forward solver (the AI version did, I just re-structured code from that a little to get less duplication).

@michael-schwarz michael-schwarz changed the title Fix Invalid_widen in MustThreadSet by replacing Reverse(ThreadSet) with Reverse(ToppedSet(FlagConfiguredTID)) MustThreadSet: Replace Reverse(ThreadSet) with Reverse(ToppedSet(FlagConfiguredTID)) Apr 1, 2026
@michael-schwarz michael-schwarz marked this pull request as ready for review April 1, 2026 13:40
Copilot AI review requested due to automatic review settings April 1, 2026 13:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the must-joined threads domain to avoid Lattice.Invalid_widen in the bu solver when threadJoins is enabled by replacing the prior “{UnknownThread} as bot” encoding with a proper reversed topped set over FlagConfiguredTID.

Changes:

  • Redefine ConcDomain.MustThreadSet as Reverse (ToppedSet FlagConfiguredTID) to give a coherent bottom/top meaning for must-joined semantics.
  • Adapt downstream analyses to pattern-match Thread ft and operate on FlagConfiguredTID.t elements.
  • Introduce ThreadSet.diff_mustset to subtract a MustThreadSet from a ThreadSet in call sites that previously used ThreadSet.diff.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/cdomain/value/cdomains/concDomain.ml Redefines MustThreadSet and adds ThreadSet.diff_mustset helper.
src/cdomains/mHP.ml Switches MHP state to MustThreadSet and updates membership/existence logic accordingly.
src/analyses/threadJoins.ml Updates join/clean logic to use MustThreadSet element type and reversed lattice semantics.
src/analyses/useAfterFree.ml Adjusts must-joined membership check to unwrap Thread ft.
src/analyses/threadId.ml Uses diff_mustset when checking “single-threaded” based on joined threads.
src/analyses/mHPAnalysis.ml Updates printing predicate to use MustThreadSet.
src/analyses/creationLockset.ml Uses diff_mustset to remove must-joined tids from possibly-running sets.
src/analyses/basePriv.ml Uses diff_mustset to avoid re-joining already must-joined threads in forced join path.
src/analyses/apron/relationPriv.apron.ml Mirrors basePriv.ml change for Apron relation privatization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cdomain/value/cdomains/concDomain.ml Outdated
Comment thread src/cdomain/value/cdomains/concDomain.ml Outdated
Comment thread src/analyses/mHPAnalysis.ml Outdated
Comment thread src/cdomains/mHP.ml Outdated
Comment thread src/cdomain/value/cdomains/concDomain.ml Outdated
Comment thread src/analyses/threadJoins.ml Outdated
@michael-schwarz michael-schwarz requested a review from sim642 April 1, 2026 15:11
@michael-schwarz
Copy link
Copy Markdown
Member

michael-schwarz commented Apr 1, 2026

This is now much more refactoring than I had hoped to do, but it should be a clean solution.

Comment thread src/analyses/threadJoins.ml Outdated
Comment thread src/cdomain/value/cdomains/concDomain.ml Outdated
Comment thread src/analyses/useAfterFree.ml Outdated
@michael-schwarz michael-schwarz requested a review from sim642 April 2, 2026 14:02
@sim642 sim642 force-pushed the copilot/fix-invalid-widen-issue branch from 3f57e11 to 8dbff69 Compare April 8, 2026 09:51
@sim642 sim642 changed the title MustThreadSet: Replace Reverse(ThreadSet) with Reverse(ToppedSet(FlagConfiguredTID)) Refactor bot of threadJoins analysis to mean uncomputed Apr 8, 2026
@sim642 sim642 added cleanup Refactoring, clean-up bug type-safety Type-safety improvements labels Apr 8, 2026
@sim642 sim642 added this to the v2.8.0 Clumsy Clurichaun milestone Apr 8, 2026
Copy link
Copy Markdown
Member

@sim642 sim642 left a comment

Choose a reason for hiding this comment

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

I force pushed a bit of interactive rebase here to clean up the Copilot history a bit but keep the manual parts still separate (instead of squashing everything).

@sim642 sim642 merged commit 3b9ed98 into master Apr 8, 2026
16 of 17 checks passed
@sim642 sim642 deleted the copilot/fix-invalid-widen-issue branch April 8, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug cleanup Refactoring, clean-up type-safety Type-safety improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid widen after join with mhp and threadJoins domains (regression 10/15)

4 participants